Voters captivated by the election-night returns thought they were witnessing a deadlocked race between Mike Bloomberg and Mark Green that could go into the wee hours.

Then, at midnight, television anchors reported a sudden Bloomberg surge of 36,000 votes – and in a flash the race was over.

By chance, many of the first results that arrived were from The Bronx, where Green won handily, accounting for at least part of his early lead.

But the anemic Bronx turnout was not strong enough to overcome Green’s paltry support in usually Democratic neighborhoods like the Upper West Side.

Bloomberg got a flood of late support from GOP strongholds in Staten Island, the last county to report its tally, and from South Brooklyn.

Campaign insiders knew almost two hours before Green’s 12:25 a.m. concession speech that Bloomberg was slowly racking up enough votes to capture City Hall.

Most of New York saw a dead-even race because reporters relied on exit polls and numbers funneled from the Board of Elections to the Police Department and, finally, to The Associated Press.

Green looked like he was holding on to a slight lead all night – 1,700 votes at 11:15 p.m., 650 votes at 11:20 p.m., 3,000 votes at 11:30 p.m.

It was too close to call.

But in reality, AP was reporting results to the public more than an hour after the campaigns were getting them from hot lines wired directly to the board.

AP New York bureau chief Sam Boyle blamed the delay on an overload of data clogging the computer pathways.

Meanwhile, inside the Bloomberg camp, supporters were predicting victory about 10:45 p.m. because their candidate had a slight lead over Green without even counting GOP strongholds in Staten Island and South Brooklyn, a campaign source said.

Green campaign lawyer Jerry Goldfeder said he knew about the same time that Bloomberg was outpacing Green all over the city.