Cook County State’s Attorney Kim Foxx is threatening to file a lawsuit to remove a convicted felon from office if he wins a south suburban mayoral election and is sworn into office.

Roger Agpawa, a candidate for mayor of Markham and the fire chief of Country Club Hills, pleaded guilty in federal court to felony mail fraud on Aug. 30, 1999.

In a letter sent on Thursday, the state’s attorney’s office told Agpawa he would be ineligible to take the oath of office for mayor. State law bars felons from being sworn in to municipal offices.

Roger Agpawa, fire chief in Country Club Hills and mayoral candidate in Markham

Agpawa doesn’t appear to have been pardoned for his conviction by the president of the United States, the letter said, asking Agpawa to respond by next Friday about whether he intends to seek a pardon and what he plans to do if he wins the April 4 election.

Agpawa said he has a legal right to run for office.

“My legal counsel knows that I have the right — just as I have the right to vote — to run for office and be elected,” he told the Chicago Sun-Times.

“If I am elected, we will deal with this,” he added. “The ultimate decision rests with the Markham village board for me to be sworn in.”

He’s on the ballot in a race against Perry Browley for a four-year term as mayor of Markham, according to Cook County election records. They’re vying to succeed David Webb Jr., who is retiring.

Browley is listed as the owner of Tumbling for Success. He grew up in Chicago’s Cabrini-Green public housing complex and coached the Jesse White Tumblers for decades, according to his campaign biography.

On Agpawa’s campaign Facebook page, he doesn’t directly discuss his 17-year-old conviction. He says only, “I’m not perfect and have made mistakes.”

In 2012, the Chicago Sun-Times reported on Agpawa’s criminal record after he was hired as the fire chief in Country Club Hills. He previously worked for the city of Markham in a variety of positions including chief fire inspector, deputy fire chief and 911 coordinator.

Perry Browley, candidate for mayor in Markham and former Jesse White Tumblers coach.

State law bars firefighters from having a felony, but the law doesn’t apply to fire chiefs because they don’t hold a sworn position, experts said.

In 2012, Agpawa sent out a Facebook message giving a “general apology” to the city of Country Club Hills.

He said he never intended to embarrass the city’s fire department and “never willfully omitted information to my new job and gave brief detail verbally because it was partially sealed.”

He was referring to an unusual move by the federal court to seal Agpawa’s 1999 plea agreement at his request. The public can’t view it, but the fact that he pleaded guilty is public, along with the fact that he got a reduced sentence because of substantial assistance he gave federal investigators.