Trailing badly in his re-election battle Tuesday night, Cook County Assessor Joe Berrios called one of his main challengers to concede the race less than two hours after the polls closed.

With 95 percent of precincts reporting, challenger Fritz Kaegi had 45.3 percent of the vote in the race for the Democratic nomination, while Berrios had 34.1 percent. A second challenger, Andrea Raila, had 20.6 percent of the vote.

Kaegi’s spokesman said Berrios — also powerful chairman of the Cook County Democratic Party — called to concede the contentious race shortly before 9 p.m.

“Good government is not a pipe dream or a fantasy in Cook County,” Kaegi declared at an election night party on the Near Southwest Side.

But Raila’s campaign called for a do-over — and a federal investigation — before the polls even closed Tuesday. Her lawyer said she also filed a lawsuit because, after all the confusion in her on-again-off-again status on the ballot, word was mistakenly sent early Tuesday to election officials to tell voters a vote cast for Raila wouldn’t count.

Last week, the Illinois Appellate Court said otherwise. But that followed a lower court’s ruling that disqualified Raila over an alleged pattern of fraud in her nominating petitions.

Jim Allen, a spokesman for the Chicago Board of Election Commissioners, acknowledged the error and said it was a result of a text that was pre-programmed after the lower court’s ruling. It was meant to serve as a reminder to election officials to pass out green-and-white notices indicating Raila had been disqualified.

But, Allen said, “we’d forgotten about that completely.” And the text wasn’t canceled after the appellate court restored Raila to the ballot.

Once the board realized what had happened, Allen said, it “sent out six different text messages saying ‘do not hand out the green and white notices.’”

Though Raila also railed Tuesday against Cook County Clerk David Orr and alleged similar problems in the suburbs, an Orr spokesman denied it.

A spokesman for the U.S. Attorney’s office also declined to comment on Raila’s request for a federal investigation.

The Berrios campaign declined to comment on the issue. A spokesman for the Kaegi campaign emailed the Sun-Times a statement that simply said, “we have heard that this error has taken place and affected a small number of precincts, and the Chicago Board of Elections has been proactive in addressing concerns.”

The press was not allowed into Berrios’ campaign party, and things were quiet early on at Apollos 2000 on the Near Southwest Side, where Kaegi planned to watch election results roll in beneath a giant chandelier ringed with gold. A DJ played Latin music and R&B with a four-on-the-floor beat. A single podium had been set up in front of a mural featuring the sun god Helios in a chariot pulled by four horses.

That’s where potential mayoral candidate and former CPS principal Troy LaRaviere said he was there to support Kaegi with whom he said he “was immediately impressed.”

No Republican is seeking the assessor’s office, although party leaders can appoint nominees before the November election. So for now, the winner of Tuesday night’s race has a clear path to victory in the general election.

Kaegi, of Oak Park, spent the contentious campaign hammering Berrios not just for hiring members of his family, but also for a property tax assessment system found to be rigged against lower income minority homeowners.

Berrios insisted he had made necessary reforms that included “streamlining the office” to cut costs and “improving the appeals process for home owners and recouping lost revenue.”

Last week, a new report found the most valuable homes in Chicago were undertaxed by an estimated $800 million over a five-year period, with the bottom 70 percent of houses picking up the burden.

However, that report followed a review by the Civic Consulting Alliance that affirmed an analysis by the Chicago Tribune and ProPublica, which found the system transfers wealth from low-income homeowners in largely minority areas to higher income homeowners.

Berrios, who lives in the Belmont Cragin neighborhood, has been assessor since 2010 following stints on the Cook County Board of Review and as a state representative.

Even before problems arose Tuesday, Raila’s lawyer had already indicated she might ask for a special election due to the confusion created by her on-again/off-again status.

“It’s going to be a long night, and we’re going to do something,” Raila told the Sun-Times.