EL PASO, Texas (AP) - Sen. Ted Cruz fended off a spirited underdog challenge from Democrat Beto O'Rourke to win re-election on Tuesday in a Texas race that once seemed like a cakewalk but needed a late boost from President Donald Trump to help push the incumbent over the top.
Cruz began as the prohibitive favorite after his surprisingly successful 2016 presidential run, but he suddenly found himself in a tough contest against O'Rourke, a little-known El Paso congressman and one-time punk rocker who became a national political sensation and shattered fundraising records despite shunning donations from outside political groups and pollster advice.
Cruz turned back O'Rourke with the help of Trump, his bitter rival in 2016. Trump took the unexpected step of traveling to reliably Republican Texas during crunch time, staging a Houston rally to energize his base for Cruz just two weeks before Election Day. The president praised the senator as "beautiful" and smart, a far cry from two years ago when he repeatedly mocked Cruz as "Lyin' Ted," made fun of his wife's appearance and suggested that Cruz's Cuban-born father had a hand in the assassination of John F. Kennedy.
With the win, Cruz kept alive his hopes of mounting a second presidential run once Trump leaves the White House.
In his victory speech, Cruz said his win affirmed that he won the "battle of ideas" against O'Rourke over issues like low taxes, reduced regulation and jobs.
"All the money in the world wasn't a match for the good people of Texas," he said, while also acknowledging that millions of people across the state were inspired by O'Rourke's campaign.
O'Rourke grabbed glowing national headlines by visiting all 254 Texas counties and often drawing large crowds - even in fiercely conservative areas other Democrats had long since written off. He raked in donations from across the country and even set a new record for Senate campaign fundraising by collecting more than $38 million in the three-month period from July through September alone. All told, he raised a whopping amount - more than $70 million.
O'Rourke even got an unexpected boost from Beyonce as the Houston native posted pictures of herself wearing a Beto baseball cap on Instantgram mere hours before the polls closed.
It wasn't enough. Thousands of supporters who attended O'Rourke's election party at a minor-league stadium in his native El Paso chanted "Beto, Beto, Beto," but the crowd got more anxious as word spread that their candidate wasn't going to prevail. Election returns that played briefly on the stadium scoreboard were pulled quickly and replaced with a local rock band on stage.
O'Rourke, his voice hoarse from the grind of the campaign, told supporters that the campaign would "lead to something far greater than today." He took a subtle jab at Trump's vow to build a border wall and at one point uttered an expletive that was captured on live television.
"I'm as inspired, I'm as hopeful as I've ever been and tonight's loss does nothing to diminish how I feel about Texas or this country" O'Rourke said.
Cruz had the support of outside groups but was still being out-raised 3-to-1 by the end of the race - a discrepancy he dismissed by saying the "hard left" was energized by outrage at Trump and "Texas will not be bought."
For months, Cruz refused to entertain the notion that he'd lose, saying there are more Republicans in Texas than Democrats, so all he had to do to win was avoid conservative complacency. He also said O'Rourke's support for impeaching Trump, relaxing federal immigration policy, decriminalizing marijuana and implementing universal health care were too liberal for even many of the state's moderate Democrats and independents.
Still, the race laid bare that many Texas conservatives never forgave Cruz for clashing with Trump at the end of the 2016 presidential primary and for refusing to endorse him at the Republican National Convention in Cleveland - a move many saw as putting personal ambitions over party. That's despite Cruz being one of the fiercest supporters of the president and the policies of the Republican-controlled Congress since then, despite getting to the Senate in 2012 as a tea party insurgent intent on enraging establishment leaders from both parties.
Cruz, 47, made no secret about wanting to run for president again once Trump leaves office. And though he was tested by O'Rourke, avoiding what would have been a monumental upset means that remains a possibility. O'Rourke himself had been mentioned as a possible 2020 White House contender - but that was dependent on him staying within striking distance of Cruz.
O'Rourke's defeat also dashed Democrats' decades-long hopes of a booming Texas Hispanic population flipping the country's largest red state blue, potentially transforming the national electoral maps and all-but blocking a Republican path to the presidency. Cruz has for years warned that a Democratic Texas would mean his party would never again win the White House.
A Texas Democrat hasn't won any of the nearly 30 statewide offices since 1994, the country's longest losing streak.
For AP's complete coverage of the U.S. midterm elections: http://apne.ws/APPolitics
(Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)