Maryland Sen. Nathaniel Oaks (D-Baltimore City) pleaded guilty to public corruption charges on Thursday, hours after he resigned from the state Senate.

Oaks pleaded guilty in federal court on Thursday to accepting more than $15,000 in bribes from an FBI agent. He could face a maximum of 40 years in prison — 20 years for charges of wire fraud and honest services wire fraud, The Washington Post reported.

Oaks, 71, was indicted in federal court in April 2017 on bribery and fraud charges after it was alleged he agreed to help with a housing development project in Baltimore in exchange for bribes from an FBI agent undercover as an out-of-state real estate developer.

The former Maryland lawmaker, who served in the state legislature for 30 years, said he was resigning “to eliminate all clouds that have hovered over the 2018 Legislative Session,” in a letter to Senate President Thomas V. Mike Miller Jr. on Wednesday night.

Despite calls by Miller and Gov. Larry Hogan to resign last year, Oaks refused to do so. Instead, he attended the final day of the legislative session last spring.

Oaks filed for re-election in February despite being removed from his seat on the Maryland Senate Finance Committee after the Joint Committee on Legislative Ethics found “numerous potential violations of the Maryland Public Ethics Law arising from the actions of Senator Oaks that resulted in the filing of federal criminal charges,” The Post reported.

Oaks is the second Maryland lawmaker to resign after being charged with corruption in recent years. On March 1, former state delegate Michael Vaughn (D-Prince George’s) was found guilty of accepting bribes for votes to expand liquor sales in Prince George’s County in 2015, according to federal prosecutors.

Oaks served in the Maryland House of Delegates in the 1980s, briefly losing his seat after being convicted of steal funds from his campaign account, before regaining it 1994, The Post reported. Last January, he was appointed to fill the seat vacated by Sen. Lisa Gladden, who stepped down for health reasons.