Cruz and O’Rourke were neck-and-neck as results came in, but the Calgary, Alta.-born Republican eventually pulled ahead. The Associated Press had Cruz with 51.1 per cent of the vote to O’Rourke’s 48.1 per cent, with 65 per cent of polls reporting.
“Texas came together behind a common-sense agenda of low taxes, low regulations and lots and lots of jobs,” Cruz told cheering supporters in Houston.
“Securing the border and keeping our community safe and defending the constitution and the bill of rights — that is a common-sense agenda that unites Texans from every part of the state.”
The 47-year-old was first elected to the Senate in 2010 on a wave of fury in the conservative Tea Party movement over then-Democrat President Barack Obama.
He went on to sharply feud with then-candidate Donald Trump during his unsuccessful bid to become the Republican candidate for the 2016 presidential election, with Trump branding him “Lyin’ Ted.”
Recently, the president softened his tone on Cruz, campaigning for him in the run-up to the midterm elections and giving him a new nickname, “Beautiful Ted.”
WATCH: Trump praises Ted Cruz and describes Beto O’Rourke as ‘overrated’
In his remarks to supporters, Cruz also offered words of praise to his rival O’Rourke, who he said “poured his heart” into his campaign.
“Millions across this state were inspired by his campaign,” Cruz said. “Let me say to all of those who worked on his campaign, all those who were inspired by him, that I am your senator as well. My responsibility is to represent every Texan.”
WATCH: Ted Cruz congratulates Beto O’Rourke after winning Texas Senate seat
O’Rourke captured the national spotlight in the build-up to the Nov. 6 midterm elections, but significantly trailed Cruz in opinion polls for much of the year.
The former punk rocker and three-term congressman declared his candidacy amid a tide of liberal anger following President Donald Trump’s rise to the presidency.
O’Rourke’s campaign raised nearly twice as much money as Cruz’s. So successful was the O’Rourke campaign’s fundraising effort that some political analysts suggested that he may have drawn donations away from incumbent Democratic senators in other states.
The El Paso-born O’Rourke embraced the Democrats’ liberal wing, speaking out in support of universal healthcare and hinting an openness to calls to abolish the U.S. Immigration and Customs Enforcement Agency (ICE).
In a state where guns have long been part of the culture, O’Rourke also dared to call for gun law reform, including more extensive background checks and a ban on assault-style rifles.
WATCH: Midterm Elections: Beto O’Rourke concedes Texas Senate race to Cruz
His defeat was cheered by the National Rifle Association, which hailed Cruz’s support for 2nd Amendment rights in a tweet posted after the result emerged.
But O’Rourke also sought to sell himself as an independent voice, saying in a September debate that he was willing to work with Trump as needed but also stand up to him on some issues.
His campaign was endorsed by several high-profile Texans, including country music icon Willie Nelson and popstar Beyonce.
The Texas Senate seat was seen as one of Democrats’ few opportunities to pick up one of the two seats they need to gain a majority in the Senate, where they are defending 26 of the 35 seats that are up for grabs.
But Cruz had history on his side — deeply conservative Texas hasn’t elected a Democratic U.S. senator since Lloyd Bentsen back in 1988.
WATCH: Reaction from winners and losers in the U.S. midterm elections
The Democrats are projected to win a majority in the U.S. House of Representatives, setting the stage for a divided Congress.
— With files from the Associated Press and Reuters