Alabama Gov. Robert Bentley has entered a deal that includes his resignation from office, a guilty plea to two misdemeanors and an agreement to never again hold public office. The embattled politician was booked on the charges on Monday, ending an episode centered around a scandal in which allegations of an extramarital affair has dogged him since last year.

With his resignation, Lt. Gov. Kay Ivey has taken the oath of office to assume the job of Alabama governor.

State legislators were preparing to open up impeachment hearings against Bentley, a two-term governor, who touted himself as a family values conservative. But evidence of the affair came about when recordings of him making sexual comments to his aide Rebekah Caldwell Mason. An investigation found that he sought to cover up the relationship and that he used public money to do so.

An investigative report prepared for the Alabama House Judiciary Committee and released last week said Bentley encouraged an “atmosphere of intimidation” to keep the story under wraps and directed law enforcement officers to track down and seize the recordings. The report portrayed the governor as paranoid and obsessed with trying to keep the relationship secret.

The committee on Monday started what was expected to be days of hearings.

The investigative report contained text messages that the governor sent to Mason. They were intercepted by Bentley’s then-wife, Dianne Bentley, who was able to read the messages because they also showed up on the governor’s state-issued iPad, which he had given her.

“I sure miss you. I need you. I want you. You are the only one,” one message read.

On Friday, the governor made a somber plea for forgiveness from the steps of the Alabama Capitol, acknowledging that he had let people down but promising that he had done nothing illegal or anything to merit his removal from office.

He has denied having a physical relationship with his former aide, though in some of the recordings he talked about the pleasure he got from fondling her breasts.

Bentley’s resignation follows the ouster of former House Speaker Mike Hubbard, who left office in 2016 after being convicted on ethics charges, and former state Supreme Court Chief Justice Roy Moore, who was suspended from his post last year over an order opposing same-sex marriage.

With Reporting by AP