Texas Sen. Ted Cruz parlayed his socially conservative stance and fervent anti-Washington message into a slim victory Monday night in Iowa’s Republican caucuses, dealing a setback to billionaire Donald Trump in the first meaningful test of the 2016 presidential campaign.

Marco Rubio finished just behind Trump, a strong showing that could offer a big boost heading into next week’s New Hampshire primary and stamp the senator from Florida the front-runner among Republicans seeking an alternative to the more ideological Cruz and incendiary Trump.

The rest of the crowded Republican field finished far behind.

One immediate casualty was former Arkansas Gov. Mike Huckabee, the winner of the 2008 Iowa caucuses, who announced he was suspending his campaign Monday even before the final votes were tabulated.

A jubilant Cruz, who has basked in the contempt of his congressional peers — Democratic and Republican alike — assailed the “Washington establishment” and said his win was a victory “for courageous conservatives across Iowa and all across this great nation.”

“Iowa has sent notice that the Republican nominee and the next president of the United states will not be chosen by the media. Will not be chosen by the Washington establishment. Will not be chosen by the lobbyists, but will be chosen by the most incredible force where all sovereignty resides in our nation, by we the people,” said Cruz, who was joined at the Iowa State Fairgrounds by his wife, Heidi, and Iowa’s firebrand GOP Rep. Steve King.

Moments earlier, a subdued Trump insisted he was pleased with his finish, even though his usual abundance of superlatives sounded flat in brief remarks to his supporters outside Des Moines.

“I absolutely love the people of Iowa,” said Trump, flanked by his downcast wife, Melania, and adult children. “On June 16, when we started this journey, there were 17 candidates. I was told by everybody, ‘Do not go to Iowa — you could never finish in the top 10.’

“We finished second, and I want to tell you something — I’m just honored. Really honored.”

By contrast, Florida’s Rubio — who more than anyone defied expectations Monday night — delivered an exultant address to supporters in Des Moines.

“So this is the moment they said would never happen,” Rubio said as his wife and young children looked on. “For months they told us because we offered too much optimism in a time of anger we had no chance….

“But,” he went on, “tonight here in Iowa the people of this great state sent a very clear message — after seven years of Barack Obama we are not waiting any longer to take out country back.”

A big turnout was supposed to benefit Trump, whose boisterous rallies drew many campaign newcomers, but that was just one prediction of many that have proved wrong in a contest that has already defied many of the usual political norms.

Iowa Republicans have a middling record of picking their party’s nominees. Only twice since 1980, when the caucuses gained import within the GOP, have voters here picked a candidate who went on to represent the party in the fall.

GOP race: Ad dollars spent per vote in Iowa

Kyle Kim

Kyle Kim

Still, the sprawling field of Republican candidates spent hundreds of days and tens of millions of dollars lavishing attention on the state and its expectant voters.

In the end, though, as most others fell away, the Iowa campaign became a fight between two political upstarts, Cruz and Trump, neither of whom were widely considered serious contenders last year when they launched their presidential bids.

Trump had talked about seeking the White House several times before, but never followed through. His disapproval rating among Republican voters was extraordinarily high and his verbal strafing of opponents, women and minorities as well as refusal to campaign in the intimate style to which Iowans have grown accustomed all seemed to weigh against his efforts.

But for many, his trampling of social and political niceties was not seen as reckless but rather as a sign of his independence and strength. Republican voters came around to Trump, making him the leader in both national and Iowa polls.

Cruz, a freshman senator, put off many fellow Republicans in Washington with his political crusades — including a government shutdown over funding of Obamacare — and refusal to collaborate. He was not even the sole Texan running on the GOP side.

But he outlasted his state’s former governor, Rick Perry, who quit the race in September, and others vying for the support of the GOP’s sizable conservative Christian wing, including Scott Walker, Wisconsin’s governor and a leader in early Iowa polls. Walker also quit in September.

As rivals fell away, Cruz emerged as the favorite of evangelicals with uncompromisingly conservative positions on issues such as abortion and same-sex marriage. When Trump gained traction pushing a hard-line anti-immigration message, Cruz matched his tough talk.

He also campaigned here in the time-tested Iowa way, by visiting all 99 counties — he hit the final one Monday — and carefully building an organization on the ground designed to maximize turnout and ensure his supporters caucused on Monday night.

The inevitable collision between Cruz and Trump, who had previously been nothing but complimentary of one another, came early last month when Trump began raising the issue of Cruz’s Canadian birthplace. Most legal experts seconded Cruz’s statements that his birth to an American citizen — his mother is a native of Delaware — automatically made him eligible for the presidency.

But some voters began echoing Trump’s concerns, especially after two other Republicans running, Rick Santorum and Huckabee, took up the attack. Cruz, after first brushing off the issue, responded by assailing Trump’s “New York values” and pointed out his previously more liberal stands on issues like abortion and healthcare.

Trump may have also hurt himself by skipping the final debate in Iowa last Thursday night. In interviews across the state, many Republicans took offense and said they regarded the decision as a snub of the voters making up their minds.

The sniping between Trump and Cruz afforded Rubio an opportunity to capitalize on in Iowa after largely skirting the state. He spent the final days of January on an extensive tour, and he clearly benefited. Entrance-poll interviews with voters arriving at their caucus sites showed many of Rubio's supporters made up their minds near the end of the campaign.

Others in the field made passing feints at competing in Iowa or, in the case of former Florida Gov. Jeb Bush — who campaigned hard and had the support of a free-spending political action committee — simply failed to connect.

For most finishing at the bottom, Iowa spells the effective end of their campaigns, though they may not quit right away. For others — including Bush and Govs. Chris Christie of New Jersey and John Kasich of Ohio, who expect to face a friendlier, less conservative electorate in New Hampshire — the Feb. 9 primary will be the test that determines whether they stay in the race.