Republican Ted Cruz and Democrat Beto O'Rourke repeatedly traded barbs during a testy first debate Friday night, underscoring how a Texas Senate race that long looked like a cakewalk for the conservative incumbent now appears to be anything but one.

Cruz went on the attack moments after stepping on the stage, charging that his opponent suggested that police officers embodied "modern-day Jim Crow" laws in response to a question about a Dallas policewoman who shot and killed her unarmed, black neighbor after mistakenly entering his apartment, thinking it was her own.

O'Rourke responded that the accusation was "simply not true." Cruz appeared to be referring to O'Rourke previously suggesting that inherent biases in the criminal justice system promote racism.

Later, when Cruz tried to say O'Rourke wanted to abolish the Second Amendment, the Democrat said it wasn't so, and the candidates sniped while the moderators pleaded for them to stop and for the audience to stop hooting. O'Rourke said Texas was ready for a senator who will protect the Second Amendment while imposing small restrictions to save lives and prevent mass shootings. He suggested those were supported by "gunowners and non-gunowners alike," but when he said the common GOP refrain after gun violence of offering "thoughts and prayers" wasn't enough, Cruz bristled.

"I'm sorry you don't like thoughts and prayers," he said. "I will pray for anyone in harm's way."

Cruz was also asked whether Supreme Court nominee Brett Kavanaugh's accuser could say anything that might make him question his support for the nomination. Cruz said "absolutely," but didn't elaborate while calling the allegations serious.

Democrats have long dreamed of flipping heavily Hispanic Texas, the country's largest red state, and transforming the national electoral map. O'Rourke is giving up his El Paso-based U.S. House seat to try and upset Cruz, even though his party hasn't won any of Texas' two dozen-plus statewide office races since 1994, America's longest political losing streak.

The debate at Dallas' Southern Methodist University also saw Cruz criticize O'Rourke's past support for legalizing marijuana, evoking his older half-sister, Miriam, who died of a drug overdose. O'Rourke, meanwhile, has been open about his 1998 arrest for drunken driving in El Paso, but said for the first time Friday that he did not try to flee the scene, as a witness suggested in the police report. He called the incident a "terrible mistake"

The pair will square off again next weekend in Cruz's hometown of Houston, and a third and final debate is set for San Antonio three weeks before the Nov. 6 election.

Cruz didn't speak to the media afterward except to say he thought the debate "went great." But O'Rourke said the senator "has a tendency to mischaracterize a position."

"If he's talking about NFL players kneeling during the national anthem at a football game to call attention to injustice in this country, he'll talk about flag burning," O'Rourke said. "If we're talking about ending the war on drugs, the war on people, and some people over other people in this country, and ending the prohibition on marijuana, he'll talk about legalizing heroin and cocaine. No one wants to do any of that."

An ex-punk rocker who has attracted glowing attention from national liberal circles for his high-energy campaign and monster fundraising, O'Rourke has been mentioned as a possible 2020 Democratic vice presidential candidate and even a 2020 White House hopeful. Though he may not knock off Cruz, the argument goes, a close loss could only further boost his national profile.

O'Rourke, however, has repeatedly insisted he has no political plans beyond this race.

He's visited all 254 Texas counties, including areas that Democrats long ago gave up on — a fact he mentioned repeatedly during the debate. Cruz dismissed many such visits as photo-ops.

Cruz finished second in the 2016 Republican presidential primary. But a variety of polls show that O'Rourke is staying within striking distance — prompting Cruz to go negative in ads lately, attacking his opponent for defending NFL players' right to protest during the national anthem and his opposition to the Trump administration's hardline stance on immigration.

President Donald Trump has announced that he'll rally in Texas for his once bitter rival Cruz next month — previously unthinkable in a state where Republicans usually rack up landslide victories.

A truck mounted with a portable billboard of a February 2016 Trump tweet declaring, "Why would the people of Texas support Ted Cruz when he has accomplished nothing for them?" was parked near Friday's debate site. It's frequently hit Texas political events since Trump announced plans to visit.

Asked Friday about Trump's 2016 criticism, which included making fun of Cruz's wife's appearance and suggesting that his Cuban-born father had a hand in the assassination of John F. Kennedy, Cruz said, "I could have chosen to make it about myself," but instead he said he worked with Trump to further Texas interests.

That ignored Cruz drawing the ire of many Texas conservatives for refusing to endorse Trump during the 2016 Republican National Convention. He eventually supported his party's candidate, though.

O'Rourke criticized Cruz during the debate for failing to rebuke Trump administration tariffs against China, which he said would hurt Texas trade interests.

Things are likely to stay nasty in coming weeks.

Asked what he admired about O'Rourke, Cruz managed to compare him to socialist Sen. Bernie Sanders of Vermont. O'Rourke drew laughs by replying simply of Cruz: "True to form."