Former Philadelphia Traffic Court Judge Willie Singletary can’t run for a City Council seat due to his felony conviction for lying to FBI agents in a corruption probe, a judge ruled Tuesday.

And former Lt. Gov. Mike Stack III, who on Tuesday successfully defended a challenge to his nomination petitions, said he was dropping his bid for one of City Council’s at-large seats because of a bad draw for ballot position that ranked him 16th out of more than 30 Democratic primary candidates.

Singletary, representing himself, had argued in Common Pleas Court on Friday that a Pennsylvania Constitution ban on certain felons serving in office does not apply to local offices like City Council. He also suggested a presidential pardon could clear his record before he took office if he won election.

Judge Stella Tsai was not swayed. In a 12-page order, she said Article 2, Section 7 of the state constitution made Singletary ineligible for the May 21 Democratic primary ballot.

That section says people “convicted of embezzlement of public moneys, bribery, perjury or other infamous crimes” cannot hold “any office of trust or profit” in the state.

Singletary, who spent 20 months in federal prison and is still appealing his 2014 sentence, said he was not giving up on running for office.

”I’m going to file an appeal,” he said in a brief phone interview Tuesday. “That’s all I can say at the moment.”

The legal blow came a week after Singletary experienced a stroke of political luck. He pulled the fourth position on the primary ballot, considered prime political real estate in a Council at-large field of more than 30 candidates.

Stack was not so lucky, pulling the relatively high number of 16 from the Horn & Hardart can the city uses for the ballot-position drawing.

“The most disappointing aspect of this effort is that the fate of my candidacy was largely at the mercy of a coffee can, an archaic and dysfunctional system for determining ballot position that is not fair to anyone and needs to be reformed,” Stack said.

He said he would work with city Democratic Chairman Bob Brady to help “build party unity for this election and the elections in 2020 when we have an opportunity to defeat Donald Trump, take back the United States Senate and win majorities in both houses of the Pennsylvania legislature.”

Stack, scion of one of Philadelphia’s political dynasties, lost the 2018 primary for reelection as lieutenant governor. Gov. Tom Wolf wanted him off the ticket after a scandal in which Stack and his wife were accused of mistreating their state police security detail and employees who worked at the lieutenant governor’s residence.

In another case, Democrat Tonya Bah lost her bid to remain on the ballot in Council’s 8th District. Attorney Kevin Greenberg had challenged her candidacy since Bah had not properly filed a statement of financial interest.

Bah, in a statement from her campaign, expressed “outrage” and said she was “carefully evaluating the court’s ruling and exploring all options.” She had been challenging Councilwoman Cindy Bass, a Democrat who now faces no primary or general election challengers.