Ted Cruz burst onto the national political scene in 2012 by winning a contentious race for for a rare open U.S. Senate seat in Texas. Six years and one failed presidential campaign later, the Texas Republican is facing an intense challenge from Democratic U.S. Rep. Beto O’Rourke of El Paso.

It’s been nearly a quarter of a century since Texas voters elected a Democrat statewide. O’Rourke’s bid to upend that losing streak remains a long shot. But as their matchup has evolved into one of country's most closely watched contests, aspects of Cruz’s original come-from-behind win in the 2012 GOP primary have emerged in his re-election bid — except this time, they apply to O'Rourke.

Here are six ways the Cruz/O’Rourke race is oddly mirroring Cruz’s first run for the seat.

1) O'Rourke's trajectory in 2018 parallels Cruz's in 2012 ... so far

For years, Cruz has often sprinkled the same anecdote in speeches: When he entered the U.S. Senate race in 2011, he was at 2 percent in the polls and the margin of error was 3 percent.

Though it often drew a laugh, it’s a fairly accurate description of what the political landscape looked like for the first-time candidate when he entered the race to replace U.S. Sen. Kay Bailey Hutchison. Many Democratic operatives agreed the seat was nearly assured to stay in Republican hands, making the primary the only election that mattered. Republican Lt. Gov. David Dewhurst was widely viewed as having the race sewn up.

Cruz campaigned around the state for most of a year as an underdog, speaking to every Republican or Tea Party group that would listen to him. By the start of 2012, he was a contender. Crucially, a legal battle over redistricting delayed the Texas primary for weeks, giving Cruz more time to amass support. He ultimately beat Dewhurst in a July runoff.

O’Rourke faced similar skepticism when he first suggested a run for the seat nearly two years ago. At the time, few thought Cruz was in serious danger of losing re-election. Many Democratic activists thought U.S. Rep. Joaquin Castro, D-San Antonio, was better positioned to challenge Cruz. Castro eventually opted out, and O’Rourke has campaigned his way into a single-digit race.

2) Cruz framed his 2012 bid as that of a grassroots champion taking on an entrenched politician. O'Rourke is running the same play.

Dewhurst invested millions of his own dollars into his Senate campaign. And the longtime lieutenant governor easily drew large donations from the state’s business interests and power players.

Cruz played that to his advantage. The comparisons he offered on the campaign trail between his own financing and Dewhurst’s sound strikingly similar to recent O’Rourke sound bites.

“My opponent’s funding came from roughly 3,000 donors — essentially every lobbyist in the city of Austin and just about every lobbyist in Washington, D.C.,” Cruz said of Dewhurst during their runoff fight. “Our average contribution was under $170. His average contribution was over $1,600 ... This is a referendum on who decides: If you want every lobbyist in Austin to decide, everyone who makes their living keeping the government gravy train going, or do you want this race decided by conservative grassroots activists?”

Six years later, the situation has flipped. Politico reported this month that Cruz is actively courting D.C. lobbyists for support in his re-election bid. And O’Rourke has made a no-PAC-money pledge a central plank of his “people-powered campaign.”

"[Texans] don't want somebody who's captured by corporations and political action committees and special interests because that's where Ted Cruz gets his money," O'Rourke said during last week's debate. "Our campaign is the largest grassroots campaign this state has ever seen, funded by people and only people."

3) Cruz's main opponent was a politician seen as overshadowed by a fellow Republican. Now Cruz finds himself in that position.

In his 2012 bid for U.S. Senate, Dewhurst had a laundry list of accomplishments to tout to the Republican base — conservative measures passed by the Texas Legislature under his watch. But Cruz argued on the campaign trail that many of those wins happened in spite of Dewhurst's leadership or even over Dewhurst’s objections. He pointed to Gov. Rick Perry as far more impactful to the conservative cause — despite Perry endorsing Dewhurst.

In the last three years, Cruz has himself seen a large shadow being cast — by Donald Trump. It began during the raucous 2016 presidential race in which Trump criticized Cruz’s wife and father. Cruz famously refused to endorse Trump at the Republican National Convention, only to change his mind weeks later. Cruz has since been a largely faithful Trump booster in Congress.

Cruz’s complicated history with the president reshaped many Texans’ perception of him. Trump is now set to travel to Texas to campaign for Cruz, who has left his descriptions of Trump as a “sniveling coward” and “utterly amoral” behind him.

4) Cruz accused Dewhurst of falsely attacking his patriotism. O’Rourke backers are making the same allegation of Cruz.

In 2012, Dewhurst’s campaign and his allies attacked Cruz for taking a case as an appellate lawyer for a Chinese tire manufacturer. One mailer featured Cruz’s face in front of a Chinese flag. Cruz accused Dewhurst of “maligning” his patriotism.

Over the past month, Cruz has launched ads against O’Rourke accusing him of disrespecting the troops and advocating flag burning, charges O’Rourke’s campaign has denied.

At a recent Washington, D.C., fundraiser, O’Rourke framed those attacks as among a series of "ridiculous fear-based campaigns" Cruz was lobbing at him.

5) Cruz had an enthusiasm advantage against Dewhurst. Now, O’Rourke appears to have such an advantage.

Whether it's the huge crowds showing up at O’Rourke's rallies or the “BETO” yard signs outnumbering Cruz ones in many Texas neighborhoods, O'Rourke is drawing a level of passion and excitement on the campaign trail that Cruz has not matched this cycle.

It was a different story in 2012, where Cruz's speeches regularly drew enthusiastic responses from growing crowds, culminating in a large, cheering rally in The Woodlands alongside former Alaska Gov. Sarah Palin days before the primary runoff. Those optics all helped Cruz to draw an even sharper contrast with Dewhurst, whose campaign events were more staid and often smaller.

6) Even before he won, Cruz’s 2012 bid prompted speculation of a run for president. These days, O’Rourke’s drawing 2020 talk.

During Cruz's winning bid against Dewhurst, conservative circles in Texas and Washington marveled at his skills as a campaigner and his talent for articulating Tea Party values. That prompted talk of Cruz's prospects as a future presidential candidate.

O’Rourke is running this year as the Democratic field for 2020 is taking shape. But, just like Cruz in 2012, his knack for conveying his base's positions in a clear and compelling way has drawn him into the pool of potential 2020 candidates. CNN included him on a list of people likely to end up as the 2020 Democratic presidential nominee. O'Rourke has waved off such speculation, but it's just another way the Democrat's run has elevated him to the national stage in a similar way that Cruz managed to do six years earlier.