DES MOINES, Iowa — Republicans picked a Washington outsider over a New York outsider in their caucuses Monday night in Iowa, while Democrats battled to a virtual tie.

The results in both parties reflect Iowans’ deep distrust of Washington, but they also suggest more establishment candidates still might have a path to their parties’ presidential nominations.

Sen. Ted Cruz of Texas rode a wave of conservative religious support and a strong campaign organization to defeat Donald Trump and a surprisingly strong Florida Sen. Marco Rubio in the state’s Republican caucuses.

In the Democratic caucuses, it was a virtual tie between former Secretary of State Hillary Clinton and Sen. Bernie Sanders of Vermont.

Both candidates claimed victory.

“It is just too late for establishment politics and establishment economics,” Sanders told supporters at a Des Moines rally.

Clinton addressed her supporters just moments earlier.

“We may have differences of opinion on how best to achieve our goals,” she said. “But I believe we have a very clear idea that the Democratic Party and this campaign stand for what is best in America.”

Cruz claimed victory at 10:20 p.m. local time.

“Tonight is a victory for the grassroots,” he said to loud applause. “Tonight is a victory for courageous conservatives across Iowa, and all across this great nation.”

In the GOP caucuses, with 99 percent of precincts reporting, Cruz had 28 percent of the vote, and Trump 24 percent. Rubio took 23 percent of GOP votes.

Trump, a flamboyant businessman who has never held elective office, showed no disappointment in his showing.

He said he would continue to battle for his party’s top prize.

“We will go on to get the nomination,” Trump told cheering supporters in West Des Moines.

Rubio’s strength will draw the attention of the Republican Party’s establishment, which is looking to coalesce around a candidate who could challenge Cruz and Trump.

“We are not waiting any longer!” Rubio told cheering supporters at his election night rally. “I thank you ... . I will be our nominee.”

Caucuses in both parties were crowded, but the meetings appeared to go relatively smoothly.

Sam Martin caucused for Rubio on Monday. He said the Florida senator was “not as extreme as Ted Cruz and he’s not as stupid as Donald Trump.”

At a Republican caucus in Clive, Cruz supporter Leah Stroh called Cruz a “Christ-centered” candidate reliably opposed to abortion. Trump, she said, is an “unintelligent” person who tells people what they want to hear.

Cruz followed a traditional electoral strategy in Iowa. His staff was in the state for months, using new data analytics to understand the electorate and to reach out to caucusgoers.

He appeared to survive his sometimes confusing criticism of government help for the ethanol industry. Many Iowans depend on the fuel blend for jobs and income.

He also survived a controversy about a last-minute mailer claiming a “violation” by voters who didn’t caucus. And Trump’s repeated assertions that Cruz’s Canadian birthplace disqualified him did not appear to have a great impact.

Trump turned conventional campaign wisdom on its head. He didn’t buy enormous amounts of television time or engage in the person-to-person politics believed to be important in Iowa. His campaign outreach was thought to be inferior to Cruz’s.

Yet he barnstormed the state in the final weeks, drawing enormous crowds and media attention. He promised to build a wall on the Mexican border, to take care of veterans and to “make America great again.”

Trump caucusers were not discouraged by the outcome. Supporter Jane Thompson was among about 100 caucusgoers filing into a middle-school library in south Des Moines to caucus for Trump.

“I’m not Republican. I am tonight,” said Johnson, who’s 65. Until last year she hated Trump, she said. Too loud, arrogant, dismissive.

“But when I heard his first political speech, he hit all the points that matter to me,” she said. “Immigration. The wall. ISIS. Social Security.”

Trump claimed endorsements from tea party favorite Sarah Palin and minister Jerry Falwell Jr. He produced a video holding up a Bible. He skipped the final debate before the caucuses, claiming disrespect from Fox News, a move that may have hurt him in the final week.

A sizable portion of the Republican establishment deeply distrusts Trump. Many aired their concerns in National Review, a well-known conservative publication, in the closing days of the Iowa campaign.

Ben Carson, a physician who also lacks political experience, had less than 10 percent of GOP caucus votes Monday.

The other Republicans _ Govs. Chris Christie and John Kasich, Rick Santorum, Mike Huckabee, Sen. Rand Paul, Jeb Bush and Carly Fiorina _ were not expected to get vote percentages in the double digits.

Huckabee said Monday night that he would leave the race.

In the Democratic caucuses, Clinton held a razor-thin lead over Sanders.

She had battled an insurgent challenge from the self-described Democratic socialist. Sanders electrified audiences across the state, particularly in college communities with younger voters, in the final days of the race.

Clinton campaigned on her experience, both in Iowa and in Washington. She argued for a moderate approach to change, and emphasized her support for President Barack Obama.

She also used the new tools of data and outreach to improve her performance in the complicated caucuses. Many compared her organizational efforts to Obama’s in 2008.

Sanders, by contrast, relied on the enthusiasm of his supporters for his caucus success. Considered the most unlikely of candidates six months ago, he was able to convince thousands of Iowans that his liberal proposals deserved consideration.

Rachel Cataldo said she’d decided Monday to caucus for Sanders. The barista said she thought he’d be a strong advocate for “the people.”

Sanders “is looking to help the young people, and the people who are not the 1 percent,” she said.

Kathy Adams, a psychiatrist nurse practitioner, said she’d long admired Clinton and had caucused for her in 2008. She was eager to support Clinton again Monday.

“She’s brilliant,” Adams said. “I think we need intelligent female energy.”

Clinton told audiences that Sanders’ ideas would be too difficult to achieve. He has argued for a new focus on wages, health care and campaign finance revisions.

Former Maryland Gov. Martin O’Malley, a Democrat, also competed in Iowa. He suspended his campaign following a poor showing there.