When Republican mayoral candidate Joe Lhota went to his polling station in Brooklyn last week, he was told his voting machine had gone kaput. He wound up using an emergency paper ballot.

When Democratic mayoral candidate Anthony Weiner showed up to vote in Manhattan, he was told his signature wasn't in the poll book. A Weiner staffer called the city Board of Elections, an error was discovered, and Weiner cast his ballot in the conventional way.

Except . . . there really is no conventional way. And most of us don't stroll into the polls with a troubleshooting aide who knows precisely whom to call.

Six days after the primary, we can only conclude that competent elections in the City of New York remain well beyond our grasp. That needs to change now.

At the moment, Bill Thompson is waiting to see if he qualifies for a Democratic mayoral runoff against Bill de Blasio, who's on the cusp of 40 percent, which would give him the nomination outright. So while the elections board laboriously canvasses 5,061 Kennedy-era lever-pull voting machines for an official tally, we wait.

That's maddening enough. But it's not the worst of the board's difficulties. In last week's elections, 8.5 percent of primary day voters wound up voting by way of affidavits or emergency ballots because of machine breakdowns, bad information and other misadventures. Utterly outrageous.

While the city has a new $95-million electronic voting system, it was sidelined for the big game last week. It can't accommodate highly detailed recounts quickly.

The board will use it in November. But don't expect our Election Day pratfalls to stop until several things happen:

The tsunami of emergency ballots and affidavits -- all painstakingly written out on paper -- must end.

Poll workers must be better trained. Stories are legion of inspectors dozing through instructional classes. And the board must ensure it has enough interpreters on hand.

Meanwhile, voter information must be kept up to date.

Mass breakdowns and a paper-intensive system are not acceptable in the computer age. We deserve better.