BIRMINGHAM, Alabama — Alabama Gov. Robert Bentley resigned on Monday after pleading guilty to two misdemeanors related to campaign finance violations and linked to his relationship with a former adviser, ending a year-long scandal that has enveloped the state’s government.

The guilty pleas were part of an agreement with prosecutors that called for him to step down, said Ellen Brooks, special prosecutor appointed by the state Attorney General Steve Marshall to investigate Bentley.

“I have decided it is time for me to step down as Alabama governor,” said Bentley at a press conference in the state capital of Montgomery, adding that his service “was a calling that God placed on my life.”

He said he would work with his replacement, Lt. Gov. Kay Ivey, who was sworn in as governor about an hour after his resignation.

Ivey, a Republican, becomes the second woman to serve as Alabama’s governor after Lurleen Wallace, wife of George Wallace, who served from January 1967 until her death in May 1968.

“What we have done today is to put an end to this administration,” Brooks told reporters. “It states to all of us that no one is above the law, even the governor.”

The Alabama Ethics Commission last week found Bentley probably violated ethics and campaign finance laws after it completed an investigation into allegations that he used public funds to conceal his relationship with Rebekah Mason, a senior adviser who later resigned.

It accused Bentley of ordering law enforcement officers to track down recordings that suggested he had had an affair with Mason and accused him of retaliating against an official who discovered the relationship.

Bentley has denied having a physical relationship with Mason, who is married, and had repeatedly vowed not to resign, saying he had done nothing illegal. His marriage of 50 years also ended as the scandal unfolded.

In his statement on Monday, Bentley apologized for his actions, but did not mention a relationship with Mason.

He was charged with misuse of campaign funds and failure to file campaign financial reports on a timely basis.

After his guilty pleas, an Alabama judge ordered Bentley to serve one year of unsupervised probation, make restitution and give up his retirement benefits from the state. He also agreed not to run for another political office, Brooks said.

After Bentley agreed to the deal, the Alabama House Judiciary Committee suspended hearings which began on Monday that could have led to his impeachment.

During the hearing, Bentley told several top aides “what happens in the governor’s office stays in the governor’s office,” Jack Sharmin, the committee’s counsel, said regarding allegations regarding his relationship with Mason.