Iowa voters on Monday night delivered a surprising win to Texas Sen. Ted Cruz in the first-in-the-nation caucuses, a victory that came after several state polls showed real estate mogul Donald Trump leading by varying margins.

Early results showed Cruz scoring nearly 28 percent of the vote, ahead of the 24 percent who voted for Trump and the surprising 23 percent who backed Florida Sen. Marco Rubio.

Retired neurosurgeon Ben Carson finished fourth with 9.3 percent of the vote. No other candidate finished with more than 5 percent of the vote. One candidate — former Arkansas Gov. Mike Huckabee, who won the Iowa caucuses in 2008 — said he would end his campaign, after finishing with just 1.8 percent of the vote.

The results stood in stark contrast to recent surveys, virtually all of which showed Trump leading. But those same surveys hinted at Rubio’s growing momentum; his surprise third-place finish, just a few thousand votes behind Trump, served to underscore Trump’s surprisingly weak showing.

But Monday was Cruz’s night; the Texas senator won 54 of Iowa’s 99 counties, including a significant number of rural counties along the state’s northern and southern borders, where evangelical voters play a larger role. Entrance polls show Cruz won evangelical voters, who made up 61 percent of caucus-goers, with 30 percent of the vote, eight or nine points higher than Trump and Rubio.

“Tonight is a victory for the grassroots,” Cruz said on the stage late Monday. “Tonight, the state of Iowa has spoken. 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, powerful force, where all sovereignty resides in our nation, by we the people, the American people.”

Rubio performed best in Iowa’s most populous counties, winning pluralities in Polk, Story, Dallas and Johnson counties. Trump, meanwhile, did best in counties along Iowa’s western and eastern borders — counties split between conservative and centrist candidates over the last two caucuses in 2008 and 2012.

“We finished second, and I want to tell you something, I’m honored. I’m just honored,” Trump said, acknowledging his second-place finish. “I think I may come back here and buy a farm.”

Entrance polls showed Cruz performed better among younger voters, while Trump outperformed among older voters. But those margins were not as divided as earlier polls had suggested.

Cruz’s advantage came among voters who called themselves very conservative. Those voters, who made up 39 percent of the electorate, favored Cruz by a 19-point margin. Voters who called themselves somewhat conservative favored Rubio, while moderates backed Trump by a nine-point margin. Republicans favored Cruz by a small margin, while voters who called themselves independents said they backed Trump.

Cruz won a plurality, 34 percent, among voters who said they chose the candidate who shared their values, while Rubio had an advantage among those, 42 percent, who wanted a candidate who would win in November. Trump, on the other hand, won 68 percent among voters who said they favored a candidate who “tells it like it is.”