Sen. Ted Cruz (R-Texas) defeated Rep. Beto O’Rourke (D-Texas) and held onto his Senate seat, Fox News projected — following a harrowing campaign that became shockingly close in a red state that hasn’t elected any Democratic candidate to statewide office in 24 years.

Cruz (pictured above right), who unsuccessfully ran for the GOP 2016 presidential nomination, has served in the Senate since 2013.

Few expected the Senate race in Texas to become as close as it did — but O’Rourke (above left) trailed as little as one percent behind Cruz in some individual polls.

But the RealClearPolitics (RCP) polling average never showed O’Rourke less than 3.2 percentage points behind Cruz since June.

Although O’Rourke narrowed the gap between himself and Cruz to 3.2 percent in mid-September, RCP’s final polling average ahead of Election Day deemed Cruz 6.8 percent ahead of O’Rourke.

In 2012, Cruz defeated Democratic challenger Paul Sadler by 15.9 percent.

O’Rourke, who made a point of personally campaigning in all 254 counties in Texas, became a liberal darling after the polling gap between himself and Cruz astonishingly narrowed. O’Rourke’s campaign had raised a record-setting $38.1 million in the third quarter, the Texas Tribute reported in mid-October.

President Donald Trump, who defeated Cruz in the 2016 GOP presidential primary, initially had a tense relationship with “Lyin’ Ted.”

Trump carried Texas in the general election by nine percentage points against 2016 Democratic presidential nominee Hillary Clinton.

Trump endorsed Cruz’s Senate re-election bid and campaigned for him in Houston in October.

Who do you think would win the Presidency?

By completing the poll, you agree to receive emails from LifeZette, occasional offers from our partners and that you've read and agree to our privacy policy and legal statement.

Related: Ted Cruz Calls Out ‘Self-Described Socialist’ Jim Carrey

“Ted’s opponent in this race is a stone-cold phony named Robert Francis O’Rourke, sometimes referred to as Beto. And he pretends to be a moderate, but he’s actually a radical open borders left-winger,” Trump told the crowd at that rally.

“O’Rourke voted against your tax cuts and he went against oil workers … O’Rourke supports a socialist takeover of health care. You’re going to triple your taxes and it won’t be enough.”

“Nobody has helped me more, with your tax cuts … He defended your jobs. He defended your borders. … He defends your families. He defends your faith, and we are defending together, with a lot of other great Republicans, your freedom,” Trump added.

Cruz also firmly aligned himself with Trump, telling the crowd, “I look forward to campaigning alongside him in 2020 for his re-election as president of the United States.”

Trump also told reporters that Cruz was “not Lyin’ Ted anymore. He’s Beautiful Ted. I call him Texas Ted.”

Cruz also firmly aligned himself with Trump, telling the crowd, “I look forward to campaigning alongside him in 2020 for his re-election as president of the United States.”

Watch this video: