More than a dozen Prince George’s County voting precincts ran out of printed ballots late Tuesday, triggering a mad rush-hour scramble in which election officials and technicians drove to the far northern and southern reaches of the county with additional supplies.

Voters, who turned out in unusually large numbers for a midterm election, waited for more than two hours at some polling sites. A similar problem occurred on a smaller scale in Burtonsville, in eastern Montgomery County.

As a result, hundreds of voters in the Democratic strongholds of Prince George’s and Montgomery were still in line when the Associated Press called the Maryland gubernatorial race for Gov. Larry Hogan (R) at 9:07 p.m., just over an hour after the polls closed.

Supporters of Democratic challenger Ben Jealous reacted with incredulity.

“How can you do that when all the votes aren’t in?” asked Del. Bilal Ali (D-Baltimore City). “It’s unfair.”

Prince George’s election officials denied any effort to suppress voters, saying that Election Day was a success for most voters. But they blamed themselves for the miscalculation.

“I take full responsibility. I apologize to voters for their experience in these affected precincts but also thank them for being patient,” said Elections Administrator Alisha Alexander, who has managed the Prince George’s elections operation for 11 years. “It was a blunder and a huge anomaly.”

Turnout was 52 percent in Prince George’s, compared with 40 percent for the midterm elections four years ago. Alexander said certain polling places were unusually active this year.

Election officials calculated the number of paper ballots sent to each of the county’s 274 precincts based on 2016 turnout, allotting enough ballots for 70 percent of the total turnout from the presidential election that year. But their formula was off for approximately 13 precincts — or about 5 percent of all Prince George’s polling places — spread across the 500-square-mile Washington suburb.

“I was stunned when we started getting calls around 4:30 p.m. saying they were dangerously low on ballots,” said Alexander, adding that the county has used similar formulas in past elections without a problem.

Election officials assembled teams of couriers to ferry more ballots from the Largo office. But rainy conditions and traffic-clogged roads delayed drivers heading in either direction. Just before 8 p.m., Maryland Democrats sent pizza to voters at the polling locations in Accokeek and Upper Marlboro, where the lines were longest.

“If there is one shining light in all of this, it’s that voters were overwhelmingly, though frustrated, patient,” Alexander said. “They were ready and stood in line. Everyone who came to cast a ballot and waited was able to exercise their right to vote.”

On the Maryland State Board of Elections website, results remained unreported for about two hours, and officials said they were aiming to refrain from posting results until voting ceased. The most affected polling stations in Prince George’s did not close until after 10:30 p.m.

Alexander said that in the future she wants to implement a plan to have enough ballots at each precinct for every eligible voter.

In Burtonsville, a scanner breakdown and other issues created long lines that left voters waiting for hours at the Marilyn J. Praisner Community Recreation Center, officials said.

David Naimon, a member of the Montgomery County Board of Elections, said the scanner broke early in the day, leaving the Praisner center with just one working machine. The center also had been an early voting site, meaning anyone could vote there, regardless of where in the county they live — leading to confusion on Election Day, when that was no longer the case.

Dozens of voters turned up at the polling location Tuesday assuming they could cast their ballot, only to be told they were in the wrong place and had to go elsewhere, Naimon said.

Like Prince George’s, Burtonsville is a largely African American area that leans heavily Democratic — a fact that Montgomery County Council member Tom Hucker (D-District 5) said made him suspicious of election officials’ motives.

“It’s an attempt at voter suppression,” said Hucker, who handed out pizza and water to waiting voters in Burtonsville, where the line snaked around the hall twice before heading out the door into the night.

Hucker called the wait time “shameful” and said he met several voters who had given up and gone home. He interviewed several of them, posting their stories to his Twitter feed.

Jealous spokeswoman Jerusalem Demsas said the campaign was concerned that voters in the precincts were not able to vote in a timely fashion. When the Associated Press called the race, Jealous tweeted to his followers: “Stay in line. Keep voting.”

Montgomery Elections Board spokesman Gilberto Zelaya said officials did everything they could to mitigate problems on a day in which turnout was high — about 54 percent, on average — at their more than 230 precincts.

“We are mandated to serve. That’s why we do this,” Zelaya said, adding that the agency plans to increase its outreach and improve contingency plans to prevent future problems.

Hucker and other Democrats had criticized an attempt to eliminate the voting site at Paisner several years ago, and Hucker said it was especially unfortunate that problems surfaced at that site.

“We have 655,000 eligible voters, and we want to serve all of them equally, but sometimes we are trying to play catch-up,” Zelaya said. “There was nothing malicious.”

Ovetta Wiggins contributed to this report.