DES MOINES — The long-anticipated Iowa caucuses turned into a debacle Monday night when technical problems delayed the results, prompting presidential candidates to depart before the outcome was clear, spurring one campaign to challenge the integrity of the process and producing a muddled situation instead of what Democratic leaders hoped would be a decisive beginning to their attempt to oust President Trump.

Hours after voters at more than 1,600 caucus sites declared their presidential preferences, Democratic officials were scrambling to explain why no results had been released and when they might materialize. As midnight neared, state party leaders met hastily with the campaigns — a phone call that ended abruptly, according to someone familiar with it — and sought to reassure the public about the reliability of a caucus system that has long been criticized as quirky and byzantine.

“The integrity of the results is paramount,” Iowa Democratic Party spokeswoman Mandy McClure said as candidates, voters and activists waited in frustration and reports circulated about problems with the app that caucus officials used to transmit the results. McClure added: “This is simply a reporting issue, the app did not go down and this is not a hack or an intrusion. The underlying data and paper trail is sound and will simply take time to further report the results.”

But it was a difficult culmination of a year of relentless campaigning by dozens of candidates and hundreds of volunteers in Iowa. The delay raised the prospect that some campaigns would continue to question the results for weeks, complicating an already tumultuous nomination fight.

In a letter sent to the Iowa Democratic Party, obtained by The Washington Post, officials with former vice president Joe Biden’s campaign questioned whether the results should be made official. “We believe that the campaigns deserve full explanations and relevant information regarding the methods of quality control you are employing, and an opportunity to respond, before any official results are released,” the letter said.

The glitch was arguably a setback for the campaigns that did well, by depriving them of a chance to declare victory Monday night, and a boon for candidates who fell short, by sowing confusion about the results. Some campaign officials said they had the impression that results could be released Tuesday, but the party made no statement in that regard.

Trump campaign officials wasted little time in fanning the flames, seizing the opportunity to sow divisions among Democrats. “It would be natural for people to doubt the fairness of the process,” campaign manager Brad Parscale said in a statement, suggesting in a tweet that it was “rigged.”

The episode is also sure to amplify complaints about the Iowa caucuses themselves. Some Democrats have long questioned not only the complex process but the fact that the first votes are taken in a largely white state that they say does not reflect the party’s growing diversity.

“This is a total mess,” tweeted Julián Castro, the former San Antonio mayor who ended his own presidential campaign several weeks ago and has endorsed Sen. Elizabeth Warren (D-Mass.). “I respect the people of Iowa, they’ve been great — but it’s become very clear that our democracy has been misserved by a broken system.”

As Monday night wore on, problems were evident across the state. In a precinct in Dubuque, the tally was delayed for more than an hour as caucus officials encountered problems reporting the numbers through the app set up by the state party.

Shawn Sebastian, secretary for a caucus in Story County, tweeted that he had been on hold for more than an hour trying to report results from his precinct to the party hotline. “The app just straight up wasn’t working,” Sebastian said in an interview.

At a caucus in Iowa City, volunteers also were not able to report the results electronically. At about 11 p.m., caucus leaders were still on hold with state party leaders as they tried to deliver the results by phone. “He couldn’t get the app downloaded on his phone,” caucus organizer John Deeth said of the official responsible for reporting the results.

Unwilling to wait longer, the candidates began speaking at their caucus night parties, making allusions to the delays. “It’s going to be a long night, but I’m feeling good,” Biden said.

“So listen, it’s too close to call,” Warren told her own supporters. “Iowa, tonight, you showed that big dreams are still possible in America.” Sen. Bernie Sanders (I-Vt.) told his crowd wryly, “At some point, the results will be announced,” adding that he was confident that when that happened, he would do well.

Pete Buttigieg, the former mayor of South Bend, Ind., took another approach altogether, essentially declaring victory despite the widespread uncertainty. “We don’t know all the results, but we do know by the time it is all said and done, Iowa, you have shocked the nation,” he said. “By all indications, we are going on to New Hampshire victorious.”

Before the results came in, the race appeared knotted among four top candidates, reflecting many Democrats’ fear of making the wrong choice to defeat a president they revile. While Sanders seemed to gain late momentum, it was far from certain that that would translate into a clear victory within the complex rules that govern the contest here.

It was a crucial moment for Biden, who entered the race as a strong front-runner but had lately sought to temper expectations in a state that was the political graveyard of his two previous presidential campaigns. Although his campaign had argued that Biden would be viable in nearly all precincts, in some early precincts he was falling short.

Warren was gambling on an elaborate organization to boost her results, while Buttigieg hoped that large crowds in the final days reflected hidden strength.

Monday’s caucuses culminated more than three years of anger and disillusionment for a party that has lacked a standard-bearer to fight back against Trump. As Iowans gathered, the Senate was in the final stages of the president’s impeachment trial, heading toward an almost certain acquittal.

The senators running for president had to race back to Iowa from Washington to make it to their caucus night parties. In another indication of the chaotic political moment, several are planning to skip Trump’s State of the Union address in Washington on Tuesday night so they can start campaigning in New Hampshire.

Early entrance polls showed that voters were motivated by health care, climate change and foreign policy. But roughly 6 in 10 caucus-goers said beating Trump was more important than agreeing with a candidate’s positions. About 3 in 10 voters said they decided which candidate to support in the past few days — about twice as many as were late deciders in 2016.

The candidates now enter an intense month, starting with the New Hampshire primary next Tuesday and culminating on Super Tuesday, March 3, when more than a dozen states hold votes.

Among the nearly 4,000 pledged delegates at the Democratic National Convention, Iowa awards just 41. But because it goes first, it plays an outsize role in setting expectations for future contests, handing some candidates momentum and leaving others struggling to justify their ongoing bids.

Because of the caucuses’ complicated rules, more than one contender may be able to claim some measure of victory. Iowans — at schools, community centers and other gathering places — began by dividing up according to their favored candidate, yielding an initial set of results, which for the first time will be released this year.

In a second round, the candidates who got less than 15 percent were eliminated and their supporters could align with other candidates, yielding a potentially different result, and one that will be used to allocate the convention delegates. Party officials have stressed that they place the most importance on who gets the biggest share of delegates.

Republicans held caucuses Monday as well, with Trump the prohibitive favorite. And the president has interjected himself in the Democratic contest, for example using a recent television interview to aim insults at the contenders.

The caucuses came after more than a year of relentless campaigning, with visits to VFW halls and diners, appearances at the hot and sticky Iowa State Fair, and flat drives past snow-topped fields.

A rollicking race that began with 28 candidates narrowed to 11, and the results here are likely to help winnow it further. But what began as a historically large and diverse field has shrunk to a group of mostly white, male, older candidates, to the frustration of many Democratic activists.

While the race has showcased differences over health care, climate change and other issues, it has been defined more than anything by the argument over who has the best chance to defeat Trump.

Sanders, who describes himself as a democratic socialist, argues that only he can mobilize a new class of disaffected voters using economic populism as a political stimulant, while Biden has made the case that Democrats need to energize black voters and working-class whites with a message of returning to normalcy after the chaos and vulgarity of the Trump presidency.

Warren has cast herself as falling somewhere in the middle, while Buttigieg — the only top candidate younger than 70 — has argued for generational change.

The caucuses were considered especially critical to the viability of Sen. Amy Klobuchar (D-Minn.), who outlasted several better-known candidates and campaigned heavily on her ability to win over Trump voters in rural, Midwestern and Republican areas. It was also a singular challenge for Andrew Yang, who has never held elective office but whose staying power has defied expectations; he is one of the last remaining minority candidates in the race.

The outcome was also important for a candidate not on the ballot: former New York mayor Mike Bloomberg. The 77-year-old billionaire was paying close attention to Iowa, hoping to emerge as a moderate alternative if Sanders or Warren performed well and Biden faltered.

Several contenders were in dire need of an Iowa win to fuel donations for campaign accounts that have dwindled after recent spending binges, with candidates investing heavily in a hoped-for victory in the state.

The Iowa caucuses were in a sense the opening chapter of a debate that Democrats will have, state by state, in the months to come.

They were the first major test of Biden’s theory that he is the most electable Democrat, a case that his campaign has been making for months. Despite low turnout at his events, his advisers were banking on the goodwill he’s built up over nearly five decades in public life.

But Democratic officials around the state have for months raised alarms about the former vice president’s campaign operation, saying he hadn’t taken the time to build an organization that would allow him to overcome the lack of fervent enthusiasm for his candidacy.

Biden’s commitment to the state also ebbed and flowed. It wasn’t until early December that he visited Ames — one of Iowa’s largest cities — and there, the first questioner rose and chided him for not being in the state as often as his rivals were. But in the past two months he came often, and in the end he and the super PAC supporting him aired $9 million in ads here.

Biden was hoping that would be enough to reverse his fortunes in a state that has spelled doom for him in the past. In 1987, he quit the presidential race after he was accused of plagiarizing from a British politician during a speech in Des Moines. In 2008, he dropped out after coming in a distant fifth in the Iowa caucuses, receiving less than 1 percent of the vote.

Warren, in turn, saw expectations for her performance grow in the final week, with a closing message focused on unity and pragmatism. “Our number one job is to beat Donald Trump,” Warren told a group of 50,000 Iowans who called in Monday for a tele-town hall, since the senator was stuck in Washington for the impeachment trial. “I think I’m the best person to do that. And I’ll tell you why: I’m the one who can pull our party together.”

She also directly addressed in recent days the question of whether a woman can beat Trump. She noted that since Trump’s victory, Democratic female candidates have prevailed more frequently than men in competitive races. “I am the only person in this race who has beaten an incumbent Republican anytime in the last 30 years,” Warren said during her tele-town hall.

Still, heading into the caucuses, it was Sanders who seemed to have the most momentum, judging by polls and crowd sizes, with some in the party bracing themselves for the possibility that he could win the first two states on a march toward the nomination.

Sanders fought Hillary Clinton to a near-draw in Iowa four years ago, losing the state to her by the slimmest of margins. This time, he was hoping to leave Iowa as the candidate everyone else is chasing — an unfamiliar spot for a politician more accustomed to running as an insurgent underdog.

Sanders’s aides have long believed that Iowa would be key to their success and have already begun looking ahead to Nevada and California, two other early states where they think they can perform strongly in the coming weeks.

It was clear heading into the caucuses that a poor showing could be a serious blow to some of the top-tier candidates and potentially reshape the race. Iowa has long been seen as a make-or-break state for Buttigieg, for example, and his campaign was particularly focused on finishing ahead of Biden.

Buttigieg spent more time in Iowa in January than his rivals did and held more than 50 town halls here in the past three weeks, the last few visibly larger and more energetic.

Beyond the candidates’ individual performances, Democratic Party officials were watching turnout numbers as a way to gauge voter enthusiasm.

Through much of 2019, officials predicted that caucus participation would break the record set in 2008, when nearly 240,000 people participated and powered a win by Barack Obama. The state party moved some precincts to larger locations and held “satellite” caucuses earlier in the day to accommodate work and child-care schedules.

While Trump did not face serious competition in his bid for the party’s nomination, the president’s campaign nonetheless sought to use the caucuses as a trial run for November and an opportunity to engage with supporters in a state that helped propel his electoral college victory in 2016.

The Trump campaign said it was dispatching more than 80 surrogates, including several Cabinet officials and Trump family members, for the caucuses, hoping to boost Republican enthusiasm in Iowa at a time when Democrats have been the main focus in the state.

The surrogates also had another task: inflaming tensions within the Democratic Party. Before the caucuses, many of Trump’s allies accused the Democratic establishment of trying to rig the election against Sanders, amplifying an evidence-free claim that the president has made repeatedly in an effort to turn Democrats against each other.

Scott Clement, Chelsea Janes, Annie Linskey, Paul Schwartzman, Sean Sullivan and Cleve R. Wootson Jr. contributed to this report.