If this election had been about politics as usual, then this story would be about Ted Cruz. The state’s junior senator just won six more years in office and the probability that he would once again be a presidential candidate by 2024. But the improbable campaign of Democrat Beto O’Rourke may have permanently damaged Cruz as a player on the national stage.

The contest played out with Cruz portraying himself as a Texas conservative who supported gun owner rights, low taxes, and stated opposition to illegal immigration. O’Rourke was an unabashed liberal who wanted to expand health care to all and protect the rights of minorities and immigrants. In a state with a broad conservative electorate in rural counties, it was not terribly surprising that Cruz won.

“This election wasn’t about me and it wasn’t about Beto O’Rourke,” Cruz said in his victory speech. “This election was a battle of ideas. It was a contest for who we are and what we believe. And the people of Texas decided this race. Texas came together behind a common-sense agenda of low taxes, low regulations and lots and lots of jobs. This was an election about hope and about the future of Texas, and the people of Texas rendered a verdict that they want more jobs and more freedom. I want to take a moment to congratulate Beto O’Rourke. He poured his heart into this campaign. He worked tirelessly and he took time away from his kids. And I want to also say, millions across this state were inspired by his campaign. They didn’t prevail and I’m grateful the people of Texas chose us. But let me say to all of those who supported him that my job is to represent all Texans.”

But early voting returns showed O’Rourke drubbing Cruz in urban areas such as Dallas, Austin, San Antonio, Houston, and O’Rourke’s hometown of El Paso. O’Rourke also was leading in suburban counties like Hays and Williamson, bookending Austin, and in Fort Bend County. Fort Bend went Democrat  in 2016, but the other two counties had fallen into the column of President Trump over Democrat Hillary Clinton.

In the 2012 election, Cruz won his Senate seat with 56 percent of the vote. That victory positioned him as a potential national power coming from a solid Republican state. He was a Fox News talk show favorite and gained national attention by reading a children’s book as part of an extended speech against the Affordable Care Act. Cruz’s appearance as a Republican king was enhanced when he won the Texas Republican presidential primary by 44 percent to Donald Trump’s 27 percent, with the rest taken by other candidates. In the end, Cruz came in second—but that was second in a very large field. Cruz’s re-election was taken for granted.

And perhaps that is why Cruz allowed O’Rourke to come on fast all through the spring and summer before starting to engage the youthful congressman. O’Rourke was receiving widespread favorable coverage in the national news media as he crisscrossed the state, attracting thousands of young voters to rallies with a promise to restore civility to American politics. It was his liberal positions defending NFL football players’ right to take a knee during the national anthem to protest police violence against African-Americans, and his defense of undocumented immigrants against family separations, that led liberals in Texas and nationally to give his campaign $70 million.

O’Rourke was the face of a changing Texas, a state becoming more urban with an increasingly tolerant youth becoming a major factor in urban politics. And in Austin, where taxes are becoming burdensome and home prices are rapidly rising, many young and more liberal families have started moving out to the suburbs in Hays and Williamson counties. Where the suburbs once were the refuge for the middle class seeking to escape inner-city problems, now they are becoming a haven for maturing Texans who are establishing their families while bringing with them this progressive ethos.

The social media fundraising campaign also broke the hold the national Democratic Party has held on Texas Senate races for decades. For two decades, the Democratic Senatorial Campaign Committee has dragged the bag through Texas, taking money out to win Senate races in other states while leaving Texas Democrats to their own devices. Since 2000—according to statistics from the Center for Responsive Politics—the DSCC has toted more than $19 million away from Texas donors and returned the favor by giving $16,500 to Ron Kirk in 2002 and $39,900 to Rick Noriega in 2008. The logic is that Texas is so big, with so many media markets, and is so expensive to even compete in, that it is better to spend the money on smaller states where victory is more possible. Money doesn’t necessarily win elections, but it certainly is needed for a candidate to be competitive.

And as soon as O’Rourke announced that he had raised $38 million in the third quarter of this year, the DSCC was eager to capitalize on it. His name became fundraising gold for the DSCC, as in this email solicitation: “Help Beto and Democrats fight back against Mitch McConnell’s cash cavalry and fight for every state — pitch in $1 now.” And. “Team — Donald Trump is barnstorming the country to help Mitch McConnell save his Senate Majority,” another solicitation read. “Now, he’s heading to Texas on Monday to campaign against Beto O’Rourke on the first day of early voting!”

Political consultants in Washington started looking at polls that showed O’Rourke could not win; some said he should transfer some of that money to competitive races around the country. O’Rourke refused, saying people gave him the money to use, not to transfer it elsewhere. Then, this week, Politico reported that political consultants were claiming O’Rourke was going to lose because he refused to employ political consultants. His was always going to be an uphill battle.

At one time, Cruz was the politician who could attract crowds and media. He rode the tea party ascendency to win the Texas Republican primary for Senate in 2012, defeating Lieutenant Governor David Dewhurst in a runoff. Cruz was a tea party favorite until he was one-upped by President Trump. They had a tough fight for the Republican presidential nomination, but since the election Cruz has been positioning himself as a political soul mate to the president. Trump came to Texas at the start of early voting to give Cruz a boost.

Cruz’s victory party was at the Post Oak Hilton in Houston. Around nine, as news spread that a few outlets were calling the race for Cruz, “Build that wall!” chants erupted from the crowd. People drifted away from the oversize TV screens showing election results and toward the stage in anticipation of Cruz’s arrival. The mood was ebullient and relieved after a closer-than-expected race and longer-than-expected wait. The biggest cheers of the night came around 9:25, when Fox News, which had been the station of choice all evening, called the race for Cruz.

The crowd at Beto O’Rourke’s election night party in El Paso grew more somber as news networks began calling the election for Cruz. O’Rourke was preparing to speak shortly, a top campaign aide said. O’Rourke has not yet conceded, but the reality was setting in with his El Paso friends.

“It’s disappointing. For me the biggest takeaway is that the politics of fear, which has been blatantly used by the Cruz campaign over the last few weeks, were obviously a little more powerful than the politics of hope and unity that Beto was preaching his entire campaign,” said Alex Neill, 40, an El Paso attorney at the reception for O’Rourke’s friends and family. “So for me, that’s a very disappointing result. On the positive side, I think he’s energized the [Democratic] Party in Texas, I think he’s energized a lot of newer voters, and maybe provided the party a kick-start.”

Writer-at-large Michael Hardy and reporter Robert Moore contributed to this report.