In theory, a Republican doesn’t have a prayer running for mayor of a city where Democrats hold a 6-to-1 voter advantage.

In practice, it’s been just the opposite. No Democratic candidate has been elected mayor since David Dinkins back in 1989.

That’s worth keeping in mind these next few months if poll after poll shows the Democratic front-runner, City Council Speaker Chris Quinn, well ahead of her Republican counterpart, Joe Lhota.

Where would Joe get his votes from?

Simple: Lhota could be sent to Gracie Mansion by a majority made up of Republicans, independents and the significant chunk of Democrats who aren’t nearly as liberal as their party’s candidates.

In the past, one essential vehicle for GOP candidates has been a third-party line on the ballot. Now, we’ve long been skeptical of New York’s minor parties, because their power tends to mischief. We saw an example this week when the Independence Party (which enjoys an automatic line on the ballot) declared for Adolfo Carrion.

Like Lhota, Carrion hopes to run for mayor as a Republican. Unlike Lhota, Carrion has been a Democrat until very recently — even serving in the Obama administration. He’s using the Independence line, which would mean a three-candidate general election, to force GOP leaders to let him run in their primary.

For Lhota, this is serious, because no Republican in recent memory has been elected without his name appearing on a second line of the election ballot.

For New Yorkers, it may be even more serious — because Lhota is emerging as the only candidate of the bunch who combines experience in making government work with a refreshing willingness to speak frankly about its limits.

“It is a fact the budget has grown 56 percent above the rate of inflation over the last 11 years,” Lhota told The Post this week.

Translation: This is a city that’s not living within its means.

Now, it’s still early days, and Lhota has much work to do to persuade a majority of New York City voters to elect him mayor.

But even without the personal fortune that helped Bloomberg win as a Republican (or the one that John Catsimatidis may use to help him), Lhota stands out as a compelling and competitive candidate.

That’s not an endorsement. It is an acknowledgment that we see few others who can be trusted not to undo the progress New York has made these past two decades — and has plausible ideas for making new advances now regarded as impossible.