SAN ANTONIO — Democrat Beto O’Rourke abandoned his usual message of unity and optimism on Tuesday and laid into Ted Cruz, hoping to reverse polls that show him fading against the Republican incumbent during the second debate of a Texas Senate race that’s become one of the nation’s most closely watched.

During the opening moments, Cruz criticized O’Rourke for past votes supporting a never-enacted oil production tax that might have hit oil-rich Texas hard. O’Rourke responded by evoking a moniker Donald Trump bestowed on the senator when the pair were bitter rivals during the 2016 Republican presidential primary, saying, “Senator Cruz is not going to be honest with you. He’s going to make up positions and votes that I’ve never held.”

“It’s why the president called him Lyin’ Ted,” O’Rourke said, “and it’s why the nickname stuck because it’s true.”

A former Ivy League debate champion, Cruz shot back, “It’s clear Congressman O’Rourke’s pollsters have told him to come out on the attack.”

Democrats have long dreamed about a growing Hispanic population helping to flip Texas from red to blue and shaking up the electoral map. But polls that once showed O’Rourke within striking distance of a monumental upset now suggest Cruz may be edging further ahead. No Democrat has won any of Texas’ nearly 30 statewide offices since 1994, the country’s longest political losing streak.

With Election Day just three weeks away, Tuesday might be one of O’Rourke’s last shots to gain ground. It was the race’s last scheduled debate after one in Houston was canceled amid Senate floor votes on Brett Kavanaugh’s Supreme Court confirmation.

Cruz wants to participate in a previously scheduled town hall featuring just O’Rourke in the US-Mexico border city of McAllen on Thursday night, but it’s unclear if that will come together in time.

The pair used this matchup to clash on abortion regulations, climate change, the Kavanaugh nomination and a border wall backed by the Trump administration. Things never got nasty or overly personal — the borrowed “Lyin’ Ted” was the only name-calling — but each candidate tried to impress voters by criticizing his opponent’s records.

When O’Rourke said he wanted to expand federally funded health care to more Americans, Cruz said the congressman agreed with Vermont Sen. Bernie Sanders and supported socialized medicine that would cost trillions and require sky-high tax increases. O’Rourke accused Cruz of not doing enough to stand up to Trump when it came to Russia and that the state needs a “full-time senator” rather than someone who concentrates on running for president.

Even when Cruz tried to say that he and O’Rourke were somewhat in agreement on opposing the Trump administration’s higher tariffs on foreign-made goods, O’Rourke drew laughs by replying, “Really interesting to hear you talk about the partisan circus after your six years in the Senate,” a reference to Cruz’s days as a tea party insurgent who battled President Barack Obama at every turn.

O’Rourke, who is giving up his El Paso congressional seat to challenge Cruz, shattered Senate fundraising records with an eye-popping $38 million-plus in the three-month period through September. The Democrat has a campaign war chest worth $22.9 million, more than double Cruz’s about $11.3 million in cash on hand.

Cruz kept O’Rourke on the defensive when they debated last month in Dallas, and O’Rourke — who had stuck to a bipartisan, feel-good message for months — kept a promise to sharpen his tone Tuesday night in front of a live audience of 120 people hosted by KENS-5, the CBS affiliate.

He also noted that his monster fundraising has come without accepting donations from outside political groups, but Cruz said O’Rourke still “goes with the left-wing national activists and left-wing national donors.”

In response to a question about the #MeToo movement, O’Rourke said Cruz “inexplicably” voted against the Violence Against Women Act, saying the senator was “all talk and no action.” Cruz countered that the movement “had done an incredible amount of good for this country” and that people of both sexes need to be protected from harassment and abuse.

Even though Cruz looks to be in a better position than earlier in the race, Trump is taking the once-unthinkable step of staging a rally in a state that’s so reliably conservative, heading Monday to an 8,000-seat Houston arena. The president carried Texas by a relatively small nine points in 2016. Still, Cruz has been a full-throated supporter of Trump since they battled during the presidential race — and hopes that the joint appearance will assuage some conservatives around the state who were angered by the past animosity.