SAN JOSE — The candidates for governor sparred over their records at a vigorous debate Tuesday night, and the arguments took a turn for the personal as several contenders’ marital infidelities were aired on center stage.

During what could be their last faceoff before the June 5 primary, the candidates rushed to fit their attacks and applause lines into the 30-second answer limit — making the forum feel at times like a contest of who could speak fastest.

The motormouthing was a sign of the debate’s high stakes. The one-and-a-half hour forum, at the lavish California Theatre in downtown San Jose, was the first time all six top governor hopefuls have appeared on the same stage since February — and the first since absentee voting kicked off this week.

And while broadsides went back and forth in several directions, there didn’t appear to be any knockout punches — including against frontrunner Gavin Newsom, the lieutenant governor, who trained more of his fire on President Donald Trump than his fellow Democrats on the stage.

In one of the most raw moments of the debate, several candidates invoked extramarital affairs by Newsom and Antonio Villaraigosa when they were mayors of San Francisco and Los Angeles, respectively, connecting their infidelities to the #MeToo movement.

“If you can’t trust Gavin with his best friend’s wife, how can you trust him with your state?” asked State Assemblyman Travis Allen, referring to the affair Newsom had with the appointments secretary in his mayoral office, then the wife of a friend. Allen, a Republican from Orange County, has personally faced allegations of making a female legislative employee uncomfortable, which he denied.

Newsom and Villaraigosa voiced deep contrition for their affairs, with both saying they had learned from their mistakes. Villaraigosa noted he had “lost his family” for a time.

Democratic State Treasurer John Chiang and former state schools chief Delaine Eastin both spoke about the importance of “character” without attacking the two former mayors by name, and Eastin said it was unacceptable “for any boss… to make passes at women who work for them.”

The debate, which was moderated by “Meet the Press” anchor Chuck Todd and hosted by NBC Bay Area and the Silicon Valley Community Foundation, was the first forum since February to include Newsom, the frontrunner in the race, who skipped a series of candidate events since then.

Some of the hottest fireworks flew between Republican candidates Allen and John Cox, a San Diego County businessman, who are competing over the same pool of Republican voters.

In a dispute over the effort to repeal the state’s gas tax increase, a popular issue with many Republican voters, Cox alleged that Allen took a $300,000 donation to support a pro-repeal ballot measure and “stole the money for his own campaign.” Allen argued that the ads he funded with that donation — which featured himself — were intended to boost the gas tax repeal effort.

In return, Allen repeatedly bashed Cox as his “angry opponent from Chicago.” He questioned Cox’s conservative credentials, telling attendees “there’s only one Republican in the race.”

Chiang, who struggled to stand out in some of the past debates, got in several jabs against Newsom and Villaraigosa. In a discussion on homelessness policy, he said “it’s important we don’t do what Gavin and Antonio did in terms of criminalizing the homeless.”

Later, Chiang accused Newsom of having “deported” undocumented children — a reference to his policy in San Francisco of referring undocumented juveniles charged with felonies to ICE. Newsom maintained that he had been a strong supporter of San Francisco’s sanctuary policy and had stood up to conservative attacks against it.

Speaking in the heart of Silicon Valley, the candidates also sketched out different positions on several tech issues. Asked about the influence of artificial intelligence on jobs and work, the Democrats stressed the need for investments in education. Newsom said the issue “will define our politics in the next decade,” while Villaraigosa bemoaned potential job losses caused by self-driving vehicles. Cox and Allen, on the other hand, called for more deregulation.

Most of the candidates said they supported the idea of a ballot measure that would require companies to disclose the personal data they collect from consumers, which is opposed by some tech companies — although they declined to take a hard-and-fast stance on the referendum itself. Villaraigosa said he’d rather see the legislature tackle the issue, while Cox declared that “the best way to regulate Facebook is to get competitors for Facebook.”

Meanwhile, Democrats competed to fire off the strongest attacks on Trump, even as the Republicans sparred over who was the most committed to the president.

Villaraigosa described California’s resistance to Trump in lyrical terms, saying the Golden State owes “a responsibility to the nation to stand up for mother liberty’s call” — while Eastin called the president a “racist misogynist.” Cox, meanwhile, noted that Trump hadn’t caused California’s housing crisis or other problems, accusing his rivals on the left of “using Trump as a foil to distract from their own mismanagement.”

The debate also offered a glimpse into the political calculations of the top-two primary, in which the two leading candidates will move on to the general election regardless of their party.

Newsom, who has led every major public poll, said he hoped to face a Republican in November — “either one of these will do,” he deadpanned. Villaraigosa and Chiang said they didn’t care who made it to the top two, as long as they were in it. A Democrat-on-Democrat faceoff would likely be more unpredictable than a more traditional Democrat-vs-Republican race, in which any Democratic contender would be a clear favorite.

The debate began with a moment of silence for former Gov. George Deukmejian, who died on Tuesday.

Several attendees lining up to get in the theatre on Tuesday afternoon said they hadn’t made up on their minds on whom to support — but were hoping to hear enough to make that decision.

“I’m looking for somebody we can trust,” said Marci Gerston, who lives in Los Altos. “It’s more about how they answer the questions than any particular issue.”

Michelle Blakely, an Oakland resident who works in early childhood education, said she liked some of Newsom’s mayoral policies but wasn’t sure whether he’d be able to put them into practice outside of ultraliberal San Francisco. “It’ll be interesting to hear if he can take lessons learned in San Francisco and apply them statewide,” she said. “I want him to sell me on how he’ll do that.”

Other voters were just interested in learning about their options — and excited to have all the candidates coming to the Bay Area. “We’ve got some tough problems in this state,” said Juanita Lott, a retired tech executive who lives in Danville. “I want to hear the experiences they’ve been through that make them ready for the job.”