TEXAS (CBSDFW.COM/AP) – Texas Republican Senator Ted Cruz has hung on to defeat Rep. Beto O’Rourke.

During his victory speech, Cruz thanked his supporters for coming together behind a “common sense agenda.”

“My hope is that Texas can help lead the way to bring this country together behind a commons sense agenda that benefits the people of Texas and the people of America,” he said.

He mentioned the race with challenger O’Rourke and the “unprecedented” amount of money raised in total between the two.

“We saw a $100 million race… All the money in the world was no match for the good people of Texas and the hard-working men and women across our state,” Cruz exclaimed in his victory speech.

Cruz said throughout the campaign O’Rourke was too liberal for Texas and there were way more conservatives than liberals in Texas.

In his concession speech, O’Rourke said, “I’m as hopeful as I’ve ever been in my life and tonight’s loss does nothing to diminish the way I feel about Texas or this country.”

O’Rourke went on to say, “Getting to be with and see all of you tonight reminds me why we set out to do this in the first place… Every single one of us, Republicans, Democrats, Independents, from the biggest of cities to the smallest of towns, the people of Texas want to do and will do great work for this country.”

Late summer polls showed the challenger within striking distance. Though more recent ones indicate that the senator has regained his footing and maintained a modest lead, the race has gone from cakewalk to far closer than expected.

Even that was a shock for Cruz, who won 10-plus contests during the 2016 Republican presidential primary and has long been considered the most powerful and popular conservative in a state full of them.

But the battle with O’Rourke proved that many Texas conservatives remained angry after Cruz clashed bitterly with Trump in 2016 and refused to endorse him during the Republican National Convention.

Though the senator has since become one of Trump’s staunchest defenders, the president nonetheless staged a massive rally in Houston just two weeks before Election Day to ensure his conservative base wouldn’t abandon Cruz.

“It’s the time for choosing. It’s the time for action. We know that the hard-left right now, they’re angry. They’re energized,” Cruz said Monday. “They’re filled with rage and hatred for the president. And that’s dangerous.”

As Cruz has embraced the White House, O’Rourke concentrated on mobilizing young voters, Texans living along the U.S.-Mexico border and people who moved to the state from elsewhere.

Combined finances between the two campaigns led to a record-setting amount of money amassed in the race at more than $100 million.

Beto O’Rourke raised more than $70 million.

“We are thrilled that Cruz will be representing the great state of Texas because we are a red state, were a state that believes in freedom,” said Dallas County Republican Party Chair Missy Shorey. “We’re a state that believes in opportunity and were a state that quite frankly very, very cutting edge of where this economy is going which is essential for us to have a leader like Ted Cruz there.”

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.

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.

Cruz had the support of outside groups but was still being outraised 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.”

“It’s the time for choosing. It’s the time for action. We know that the hard-left right now, they’re angry. They’re energized,” Cruz said Monday. “They’re filled with rage and hatred for the president. And that’s dangerous.”

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.

“My confidence is in the people of Texas,” O’Rourke told reporters on Monday night, moments before staging a raucous rally with Mariachi band at the University of Texas at El Paso, mere blocks from his home. “I think we have every indication, based on turnout so far, that we’re going to have a very good day tomorrow.”

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.

During his victory speech, Cruz made it clear about the “hope” and “future” he sees for Texas after his win.

“This was an election about hope and about the future. And the people of Texas rendered a verdict that we want a future with more jobs and more security and more freedom,” Cruz said.

(© Copyright 2018 CBS Broadcasting Inc. All Rights Reserved. The Associated Press contributed to this report.)