DES MOINES, Iowa — It took seven and a half hours, but Hillary Clinton just barely held off a challenge by Bernie Sanders in tonight’s Iowa caucuses.

In the end, the Vermont senator’s groundswell of excitement and youth support proved unable to match the former secretary of state’s organizational structure in a state where turnout of supporters is key.

The Iowa Democratic Party gave the win to Clinton early Tuesday morning with 49.9 percent of the vote. Sanders ended the night with 49.6 percent. Ninety precincts’ results were missing in the hours following the caucuses, delaying the results.

Supporters watch returns at a rally for Hillary Clinton in Des Moines. (AP/Andrew Harnik)

Supporters watch returns at a rally for Hillary Clinton in Des Moines. (AP/Andrew Harnik)

The race was incredibly close — at least three precincts were reportedly decided by coin toss. In each reported instance, Clinton won the toss.

More than 171,000 voters participated in the closest Iowa Democratic caucus in history, according to the Iowa Democrats.

One county remained outstanding, but it was worth too few delegates to make up the difference.

“Hillary Clinton has won the Iowa Caucus,” Hillary for America Iowa state director Matt Paul said in a statement. “After thorough reporting – and analysis – of results, there is no uncertainty and Secretary Clinton has clearly won the most national and state delegates. Statistically, there is no outstanding information that could change the results and no way that Senator Sanders can overcome Secretary Clinton’s advantage.”

But for a candidate plagued by high expectations as a near-presumptive nominee, Monday’s results were worse than the Clinton campaign had hoped.

Sanders, a Democratic socialist who’s mounting a long-shot bid against the former First Lady, finish in Iowa adds more energy to his campaign heading into New Hampshire next Tuesday, where he has an 18-point lead in the Real Clear Politics polling average.

Clinton’s victory in Iowa shores up her footing somewhat heading into the next contest — with even a narrow Iowa win under her belt, a potential loss in New Hampshire won’t be quite as painful.

As results rolled in, news broke that third-place candidate Martin O’Malley will suspend his presidential campaign.

Clinton’s campaign strategy reportedly included bolstering O’Malley so that his supporters wouldn’t go to Sanders. But it was either not followed or unsuccessful — O’Malley needed 15 percent support in each caucus location to reach “viability,” or else his supporters had to move to their second-choice candidate.

But O’Malley ended up pulling less than 1 percent of the vote, which means that his campaign was viable almost nowhere.

Follow the author of this story on Twitter and Facebook: