MONTGOMERY — Gov. Robert Bentley pleaded guilty to two misdemeanors and resigned from office Monday, felled by a sex scandal and alleged coverup.

The governor resigned as part of a plea deal agreed to at the Montgomery County Courthouse, according to an announcement from the attorney general's office, and acknowledged his guilt on two charges related to campaign finance.

A short time later, Bentley announced his resignation in an address to reporters, government officials and tourists who happened to be in the State Capitol.

“I’ve not always made the right choices,” Bentley said. “I’ve not always said the right things.”

Bentley referred to his “sins” and said that “there have been times that I’ve let you and the people of this state down, and I’m sorry for that.”

Once a popular Republican governor in a deep-red state, Bentley faced impeachment hearings in the House of Representatives this week, as lawmakers looked into allegations that the governor had an affair with a top married staffer and tried to use state police to hide it.

"His loyalty shifted from the state of Alabama to himself," special counsel Jack Sharman told the House Judiciary Committee in impeachment hearings Monday.

Rebekah Mason

Rebekah Mason listens as then-Gov. Robert Bentley delivers his State of the State address at the Alabama State Capitol in February. (Stephen Gross/The Anniston Star/file)

Bentley's administration has been in crisis since March 2016, when the governor fired former state law enforcement director Spencer Collier. Collier accused Bentley of an affair with Rebekah Mason, a married political staffer who once was a state employee but later served on the governor's staff while being paid through campaign funds and by a nonprofit that doesn't disclose its donors.

Many in Montgomery believed Mason's pay arrangement might get the governor in trouble with state ethics officials, but it was the affair allegation that riveted the public's attention for a year. Bentley was caught in lewd talk with Mason in a recording that was leaked to the press.

Sharman Monday said it was that tape — more specifically, Bentley's attempt to find and hide it — that caused Bentley to cross into impeachable behavior.

"What is important is that the relationship explains the motive," Sharman said. He said the issue at stake "is not a burlesque of text messages but rather power and its misuse."

Sharman in the Monday hearings said the recording was made by the governor's former wife, Dianne, who suspected an affair. Bentley on hearing of the recording tried to send law enforcement officers to investigate the first lady's aide Heather Hannah, whom he believed had made the recording, and sent them to obtain copies of the recording from others who supposedly had it.

"Gov. Bentley became focused, and then obsessed, on the existence of the tapes," Sharman said.

Sharman said the Bentley affair was less like the impeachment of President Bill Clinton — a sex scandal — and more like the resignation of Richard Nixon, accused primarily of a coverup.

The committee abruptly recessed around 2:30 p.m. as rumors of a pending resignation grew.

By 5 p.m., the Montgomery County Jail had posted a mugshot of the smiling governor, along with confirmation of his arrest on misdemeanor charges.

Under his plea deal, Bentley will pay more than $7,000 in fines and fees, replay more than $8,900 to his campaign and render 100 hours of community service in his old profession as a physician. He also agreed never to seek or serve in public office again.

The charges seem to stem from a ruling last week by the Alabama Ethics Commission, which found probable cause that Bentley misused state resources, made an illegal loan to his campaign to pay his and Mason’s legal costs and accepted an illegal campaign contribution when he allowed the Republican Governor’s Association to reimburse his campaign for a trip with Mason to a convention in Las Vegas.

Bentley’s critics said the House, spurred on by growing public disaffection with Bentley, would have voted for impeachment given the chance.

“I’m glad to see that he did the right thing,” said Rep. Ed Henry, R-Hartselle. “I wish he would have done it sooner.”

Bentley and Ivey

Then-Lt. Gov. Kay Ivey listens to Robert Bentley deliver his State of the State address at the State Capitol in February. (Stephen Gross/The Anniston Star/file)

Bentley’s resignation moves Lt. Gov Kay Ivey into the governor’s office, making her the second female governor in the state’s history. State Senate President Pro Tempore Del Marsh, R-Anniston, will take Ivey’s role as president of the Senate, but there’s no provision in the state constitution for replacing a lieutenant governor in mid-term.

"The Ivey administration will be open, it will be transparent, and it will be honest," Ivey said after her swearing-in, an hour after Bentley announced his resignation.

Ivey announced no new plans in her brief speech, talking instead about an orderly transition of power. She entered and left the Old Senate Chamber to loud applause.

Bentley was popular in his first term, so much so that in 2014, The Washington Post listed him as one of a handful of governors who were popular enough in their own states to consider a run for president. Bentley at the time thought he'd have a shot at president if he did run.

“People vote on emotion and on gut instinct, if you’re in the ballpark of common belief,” he said at the time.

But the governor's popularity began to crumble even before news of the affair broke. Within weeks of his election, he acknowledged a major shortfall in the state budget and proposed more than half a billion dollars in new taxes to fill it. The proposal was at odds with his 2014 campaign slogan — "More jobs, less government, no new taxes" — and he lost clout with fellow Republicans because of it.

The former Tuscaloosa doctor never collected a salary as governor. He pledged not to take pay until Alabama reached "full employment," roughly the same numbers the state saw before the 2008 recession. The state did recover, but job growth lagged behind most other states.

One success for Bentley was an expansion of the state's pre-kindergarten program, which Bentley saw as a cure for many of the state's educational ills. He successfully sold lawmakers on expansion of the program every year after he took up the cause.

His plans for the state's overcrowded prisons didn't fare as well. This year was Bentley's second try at passing a major building plan for more penitentiaries to replace prisons that are at about 170 percent of their built capacity. Lawmakers rejected the bill last year, citing a lack of detail in the plan.

A new version of the bill now awaits approval in the House, but lawmakers aren't optimistic about its passage.

Bentley is the third major Alabama official to leave office within a year. House Speaker Mike Hubbard was convicted on felony ethics charges last year and Supreme Court Chief Justice Roy Moore was suspended from office for defying the U.S. Supreme Court's ruling on same-sex marriage.

Capitol & statewide reporter Tim Lockette: 256-294-4193. On Twitter @TLockette_Star.