EL PASO, Texas (Reuters) - In one of the biggest challenges for his party in Tuesday’s elections, Beto O’Rourke hoped to oust Republican Ted Cruz and become the first Democrat elected to the U.S. Senate from the deeply conservative state of Texas in three decades.

The 46-year-old former punk rocker and three-term U.S. congressman captured the national spotlight and smashed an 18-year-old fundraising record - raising $61.8 million during his campaign, almost twice his rival’s $35.1 million - but significantly trailed Cruz in opinion polls for most of the year. Recent polls showed the race tightening, although Cruz still led.

Their paths to Senate candidacy shared a common root. O’Rourke declared his candidacy in an environment of rising liberal anger following Republican President Donald Trump’s rise to power. Cruz, 47, was first elected to the Senate in 2010 on a wave of fury in the conservative Tea Party movement over Democratic then-President Barack Obama.

The Senate seat is seen as one of Democrats’ few opportunities to pick up one of the two seats they need to gain a majority in the chamber in Tuesday’s elections. Democrats are viewed as having a good chance of taking over the U.S. House of Representatives; if the party also controlled the Senate it could further block Trump’s agenda, notably his ability to appoint more judges to lifetime positions on the Supreme Court.

O’Rourke, of El Paso, has embraced the Democratic Party’s liberal wing, supporting universal healthcare and expressing openness to calls to abolish the U.S. Immigration and Customs Enforcement Agency (ICE).

Cruz, of Houston, feuded with Trump during his unsuccessful 2016 White House run but has since embraced the president’s agenda, backing his tough immigration policies as well as his push for import tariffs aimed at lowering the U.S. trade deficit in goods. Cruz has tried to paint O’Rourke as out of step with the priorities of conservative-leaning Texans.

“There is no race in the country with a starker divide than this U.S. Senate race here in the state of Texas,” Cruz told a cheering crowd at an October campaign rally in Plano.

Slideshow ( 6 images )

O’Rourke has tried to position himself as a more independent voice, saying in a September debate he would be “a senator who will work with the president where we can and stand up to him where we must.”

“We want all of us, Republicans and Democrats, Independents alike to come together and do something great for this country. That’s what I’ve heard from the people of Texas over the last 22 months,” O’Rourke said on Tuesday after casting his vote in El Paso, Texas.

In an October debate, O’Rourke used a taunt from Trump’s presidential campaign, calling his rival “Lyin’ Ted.”

Trump, however, abandoned that nickname, calling Cruz “Beautiful Ted” at an Oct. 22 rally in Houston.

The Democrat also dared to challenge one common orthodoxy in the state, calling for reform of gun laws, including stricter background checks and a ban on assault-style rifles. Cruz criticized O’Rourke for that in a state where guns have long been part of the culture.

Alvaro Mangual, a 40-year-old pharmaceutical sales associate who lives in Houston and is originally from Puerto Rico, said he voted for O’Rourke despite being a registered Republican. He cited immigration as a key issue for this election.

Slideshow ( 6 images )

“Being an immigrant, I want things eased up,” said Mangual. “My wife is from Mexico. The ordeal her family went through with immigration was too much.”

Some political analysts have suggested that O’Rourke’s fundraising success may have drawn donations away from Democratic incumbent senators in other states.

Some 10 such incumbents are up for re-election on Tuesday in states that Trump carried in 2016, and the party can ill afford for any of them to lose if it wants a chance of gaining a Senate majority.

National attention and strong fundraising is no guarantee of success for a Texas Democrat. Former state Senator Wendy Davis leveraged her fame from an ultimately unsuccessful filibuster against a restrictive abortion law into a high-profile 2014 gubernatorial race - which she lost to Republican Greg Abbott.

Texas last elected a Democratic U.S. senator in 1988, when Lloyd Bentsen won his fourth six-year term in office. Bentsen stepped down in 1993 to become Treasury secretary under Democratic President Bill Clinton. Five months later, the Democrat appointed by then-Governor Ann Richards to succeed Bentsen was voted out in a special election.