MONTGOMERY, Ala. — Gov. Robert Bentley resigned Monday, his power and popularity diminished by a sex scandal that staggered the state, brought him to the brink of impeachment and prompted a series of criminal investigations.

Ellen Brooks, a special prosecutor, said Mr. Bentley quit in connection with a plea agreement on two misdemeanor charges: failing to file a major contribution report and knowingly converting campaign contributions to personal use. He pleaded guilty Monday afternoon.

It was a stunning downfall for the governor, a Republican who acknowledged in March 2016 that he had made sexually charged remarks to his senior political adviser, Rebekah Caldwell Mason.

“I have decided it is time for me to step down as Alabama’s governor,” Mr. Bentley said at the State Capitol. He did not mention the charges to which he pleaded guilty, or the deal with prosecutors that mandated his resignation.