Cruz's victory over Trump was a testament to his massive get-out-the-vote operation in Iowa and the months he spent wooing the state's influential conservative and evangelical leaders.
"Iowa has sent notice that the Republican nominee and next president of the United States will not be chosen by the media, will not be chosen by the Washington establishment," Cruz said.
Trump, the supremely confident real estate mogul, sounded humble in defeat, saying he was "honored" by the support of Iowans. And he vowed to keep up his fight for the Republican nomination.
"We will go on to easily beat Hillary or Bernie or whoever the hell they throw up," Trump told cheering supporters.
Clinton took the stage at her own campaign rally saying she was "breathing a big sigh of relief" but with the Democratic race too close to call. Well aware that even a slim victory over Sanders would reinvigorate questions about her candidacy, she foresaw a long race to come.
"It is rare that we have the opportunity we do now, to have a real contest of ideas, to really think hard about what the Democratic Party stands for and what we want the future of our country to look like," Clinton said.
For her supporters, the exceedingly tight race with Sanders was sure to bring back painful memories of her loss to Barack Obama in 2008. Her campaign spent nearly a year building a massive get-out-the-vote operation in Iowa yet still seemed to be caught off guard by the enthusiasm surrounding Sanders.
A self-declared democratic socialist from Vermont, Sanders drew large, youthful crowds across the state with his calls for breaking up big Wall Street banks and his fierce opposition to a campaign finance system that he says is rigged for the wealthy.
Cruz modeled his campaign after past Iowa Republican winners, visiting all of the state's 99 counties and courting influential evangelical and conservative leaders. While candidates with that portfolio have often faded later in the primary contest, Cruz's campaign says it has the financial resources to maintain viable for months.
Trump and Rubio were battling for second place, ensuring a stronger-than-expected finish for the Florida senator regardless of his exact standing in the vote tally. Rubio is a favorite of more mainstream Republicans and hoped to use the Iowa results to urge the party establishment to coalesce around his candidacy.
"We have taken the first step, but an important step, to winning the nomination," Rubio said at a campaign rally in Des Moines. He congratulated Cruz, saying he'd "earned his victory."
Iowa has decidedly mixed results in picking eventual nominees. The past two Republican caucus winners - former Arkansas Gov. Mike Huckabee and former Pennsylvania Sen. Rick Santorum - faded as the race stretched on. But Obama's unexpected 2008 victory was instrumental in his path to the Democratic nomination.
Candidates this year faced an electorate deeply frustrated with Washington. While the economy has improved under President Obama, the recovery has eluded many Americans. New terror threats at home and abroad have increased national security concerns.
Voters at Republican caucuses indicated they were deeply unhappy with the way the federal government is working. Half said they were dissatisfied and 4 in 10 said they were angry, according to surveys conducted by Edison Research for The Associated Press and the television networks.
Six in 10 Democratic caucus-goers wanted a candidate who would continue Obama's policies. Young voters overwhelmingly backed Sanders.
Both parties were drawing new voters. About 4 in 10 participants in each party said they were caucusing for the first time.
In Iowa, which has for decades launched the presidential nominating contest, candidates also faced an electorate that's whiter, more rural and more evangelical than many states. But, given its prime leadoff spot in the primary season, the state gets extra attention from presidential campaigns.
The caucuses marked the end of at least two candidates' White House hopes. Former Maryland Gov. Martin O'Malley ended his longshot bid for the Democratic nomination. Huckabee dropped out on the Republican side.
Republicans John Kasich, Chris Christie and Jeb Bush were all spending Monday night in New Hampshire - not only to get a jump on the snow moving into Iowa but also to get ahead of their competitors in a state with voters who are expected to be friendlier to more traditional GOP candidates.
While both parties caucused on the same night in Iowa, they did so with different rules.
Republicans vote by private ballot. The state's 30 Republican delegates are awarded proportionally based on the vote.
Democrats form groups at caucus sites, publicly declaring their support for a candidate. If the number in any group is less than 15 percent of the total, they can either bow out or join another viable candidate's group.
Those final numbers are awarded proportionately, based on statewide and congressional district voting, determining Iowa's 44 delegates to the national convention.
The Associated Press contributed to this report.