DES MOINES — Troy Price, the Iowa Democratic Party chairman who has been under siege since the state’s caucuses last week were engulfed by chaos that embarrassed the party, will step down as soon as a replacement can be found, he said in a letter Wednesday.

The 39-year-old, who has held the state party’s top position since 2017, announced his decision to the state party’s central committee more than a week after the closely watched caucuses were thrown into disarray by a technological glitch. The problems delayed the reporting of the outcome and cast a harsh spotlight on mathematical irregularities in the results.

The Associated Press still has not called the race because of the lingering uncertainties, and two candidates — Sen. Bernie Sanders (I-Vt.) and former South Bend, Ind., mayor Pete Buttigieg — have claimed victory. Each is also seeking a partial recanvass, questioning whether delegates were allocated properly across a range of precincts. The episode has renewed calls for the caucuses to be scrapped altogether.

This year’s event, which Price once promised would be “the most successful caucuses in our party’s history,” instead became a punchline, ridiculed by comedian Steve Martin at the Oscars as well as by President Trump’s campaign manager, Brad Parscale, who described the process as the “sloppiest train wreck in history.”

Meanwhile, 2,600 journalists from 26 countries were watching the caucuses, long held out by Iowans as a model of civic participation, as citizens gathered in school gyms, community centers and other hometown sites to kick off the nominating process.

Now, it’s not even clear if Iowa can hold on to its first-in-the-nation status.

“The fact is that Democrats deserved better than what happened on caucus night,” Price said in his letter to the party committee. “As chair of this party, I am deeply sorry for what happened and bear the responsibility for any failures on behalf of the Iowa Democratic Party.”

He added: “While it is my desire to stay in this role and see this process through to completion, I do believe it is time for the Iowa Democratic Party to begin looking forward, and my presence in my current role makes that more difficult.”

Price faced sharp criticism from some campaign operatives and party strategists, who complained that the crisis was mishandled in ways that went beyond the botched vote-counting.

Just hours after the caucuses concluded on the night of Feb. 3, one of Price’s deputies, on a call with representatives of the campaigns, repeated a cursory statement that had already been released to the press and then hung up, according to a participant who spoke on the condition of anonymity to describe private conversations.

When Price faced pointed questions on a second call that night, he scarcely deviated from the same talking points, saying the difficulties stemmed from new requirements for collecting data at 1,765 precinct locations. He concluded the conversation abruptly, the participant said.

Joining the criticism were national party leaders. Tom Perez, chair of the Democratic National Committee, called the events in Iowa “unacceptable” and placed the blame on Price’s operation, telling CNN, “The Iowa Democratic Party runs the caucus, okay?”

Price’s allies, however, pointed the finger back at Perez, saying he failed to take his share of responsibility. Michael Kiernan, a former Iowa Democratic Party chairman, said Price’s resignation offers a stark lesson for other state Democratic leaders.

“This is a warning message for other state party chairs for what Tom Perez will do to you,” Kiernan said. “There’s been no backup from the DNC. Tom Perez threw him under the bus.”

Price’s departure was widely expected by current and former party leaders, who said the U.S. Senate race in Iowa, among other high-stakes contests this November, compelled the party to move past the embarrassing spectacle relatively quickly.

An online petition calling for Price’s resignation began circulating in recent days, and police were patrolling his block after a sign was found on the interstate that said, “Troy Price will pay the price,” according to two people familiar with the matter who spoke on the condition of anonymity to divulge sensitive matters.

Amid the fallout, an organizer with the state party received a death threat last week, one of the people said.

Some Democrats were surprised the move didn’t come sooner, while others said they had anticipated that Price would at least see through the formal certification of the caucus results, which is required by Feb. 29.

“I thought he would stay through these final counts being calculated,” said Bret Nilles, the Democratic Party chairman in Linn County, Iowa, which includes Cedar Rapids.

The state party on Wednesday acceded to requests by Sanders and Buttigieg to conduct a partial recanvass of the caucus results, checking data on math worksheets completed at individual sites against publicly released numbers.

If the campaigns give the go-ahead, the process is expected to last two days and could ultimately lead to a recount, which would involve an individual check of each of the “presidential preference cards” completed by caucus-goers. Even though the campaigns requested the recanvass, they must agree to fund it before it can proceed.

Nilles said Price faced “enormous pressure” as the public face of the kickoff to Democrats’ long-awaited process of choosing a nominee to face Trump. Once that launch became a wound for the party, he said, “There was no choice, really. It was necessary so we can come together.”

The chairman’s resignation will be effective upon the election of a replacement.

Price previously served as the state party’s executive director, as well as political director for Barack Obama’s 2012 Iowa campaign and Hillary Clinton’s 2016 Iowa operation.

He is also an LGBT rights advocate, having served as the executive director of One Iowa, an LGBTQ advocacy organization. Raised in Durant, in eastern Iowa, Price earned his degree in political science from the University of Iowa and worked in the administrations of Govs. Tom Vilsack and Chet Culver.

He took over leadership of the party at a perilous time for Iowa Democrats, following allegations that the party had put its thumb on the scale for Clinton during her razor-tight race against Sanders in the caucuses.

He oversaw efforts to reform the storied caucus process by making it more accessible — first through telephone-based “virtual caucuses,” an idea nixed by the national party because of security concerns, and ultimately through satellite locations designed for Spanish speakers, night workers and others who might have trouble attending a traditional precinct.

These reforms in access and transparency, however, clashed with the technology challenges, as the state party chose a mobile app for reporting results on caucus night. The app, developed by the tech firm Shadow, was rolled out at the last minute to volunteer caucus leaders, who encountered difficulty downloading the software and logging in. Some dispensed with it altogether and opted for the backup hotline number, which resulted in jammed phone lines.

Finally, a coding issue on the back end of the software threw off the numbers as they were fed to the state party, forcing Democratic officials to revert to paper records that they scrambled to gather from across the state. The cascading problems prevented the party from releasing any results until the following afternoon, and then officials struggled to rectify errors in the numbers as the figures dribbled out over the course of the week.

Even now, there remain questions surrounding the process. Addressing reporters this week, Price could not say how many caucus chairs had successfully downloaded the app or when they began training on the software.

He described the DNC as “a partner in this process” but said little more.

“There’s going to be a time to assign blame,” he said.