Virginia gubernatorial candidates Terry McAuliffe (D) and Ken Cuccinelli (R) sparred over fundraising tactics. McAuliffe also attacked Cuccinelli's past remarks on gays that he says almost cost Virginia jobs. (Courtesy NBC4/WRC-TV)

Democrat Terry McAuliffe and Republican Ken Cuccinelli II brought their bitterly personal battle for governor to a crucial debate in Northern Virginia on Wednesday night, each casting the other as unfit for office, untrustworthy and wrong for the commonwealth.

McAuliffe hammered Cuccinelli, the state’s attorney general, on conservative social stances that he contends are too extreme for Virginians. And Cuccinelli said McAuliffe, a former Democratic National Committee chairman who has never held elective office, lacks the gravitas and experience to lead the state.

“There are consequences to this mean-spirit attack on women’s health, on gay Virginians,” McAuliffe said. “If we’re going to build a new economy in Virginia, we’re going to do it by bringing everyone together.”

( Read a transcript of the debate )

Cuccinelli fought back by highlighting two recent business endorsements and the softer side of his record, including working with homeless and mentally ill people, helping to free a wrongly convicted man, and establishing a program to help victims of sexual assaults on college campuses.

“I’m the only candidate in this race with a lifetime of fighting for Virginians,” Cuccinelli said. “I’ve also served in state government for over 10 years. And I know how it works. I’m the only candidate in this race who won’t need on-the-job training.”

The debate came at a pivotal moment in the race for governor, with recent polls showing McAuliffe building a small but solid lead. Yet both candidates carry political baggage that has limited their likability with voters and given each an opening to attack the other.

McAuliffe linked Cuccinelli to the tea party movement that has helped fuel a threat to shut down the federal government, while Cuccinelli cast his opponent as a glib operator who improperly mixes business and politics.

“If Terry becomes governor, we’ll have to change the state’s motto from ‘sic semper tyrannis’ to ‘quid pro quo,’ ” Cuccinelli said.

Earlier, he said: “My opponent has spent a lot of time telling you why you shouldn’t vote for me for governor but not much time telling you why you should vote for him.”

There was no obvious gaffe in the debate, and the sparring ­featured no game-changing ­pronouncements or exchanges. When McAuliffe said he would sign legislation to legalize gay marriage, Cuccinelli corrected him on a point of process: That sort of change would not come by way of a bill but as an amendment to the Virginia Constitution.

Both men ducked questions: McAuliffe on the cost of raising teachers’ salaries, funding pre-kindergarten programs and other priorities on his agenda; Cuccinelli on what tax loopholes he would close to pay for his promised $1.4 billion tax cut. Speaking to reporters afterward, Cuccinelli said it would take him a year to determine what to eliminate.

Cuccinelli also ducked a question about why he accepted $18,000 in gifts from a Richmond area businessman, instead pointing to the fact he met the businessman through Gov. Robert F. McDonnell (R).

The recent polls highlighted what has become a central theme of the race: Cuccinelli’s record on issues of importance to women. The topic arose during the debate, with McAuliffe casting Cuccinelli as a threat to women, and Cuccinelli on the defensive.

McAuliffe cast himself as a bipartisan businessman who would place the state economy above everything. He emphasized that he would govern as a moderate, repeatedly invoking the word “mainstream” and the fact that some Republicans have crossed party lines to endorse him.

When asked about a Virginia law that prevents many school districts from opening before Labor Day, McAuliffe said he supports it because it helps the tourism industry.

“The tourism business is too important,” he said.

Cuccinelli shot back: “Children outrank tourism.”

The Republican sought to cast himself as the only experienced leader in the race. His effort to soften his image came just days after two new polls showed that nearly half of all voters view him unfavorably.

Cuccinelli had some of the best lines of the night, which came as a surprise given the former engineer’s generally understated manner and his dour tone in the last debate. “Unlike my opponent, I do my homework,” Cuccinelli said, playing up a narrative that came into focus after McAuliffe bungled an endorsement interview with a business group.

On gun control and the recent Washington Navy Yard shooting, Cuccinelli said the answer was better mental-health care. McAuliffe said he supports universal background checks for gun buyers. On the threat of a government shutdown over whether to defund the Affordable Care Act, Cuccinelli countered that although he wants to defund Obamacare, he also recognizes that both parties must compromise.

“None of us want to see a government shutdown,” Cuccinelli said, declining to say whether he supports efforts by Sen. Ted Cruz (R-Tex.) to delay funding legislation and force a confrontation in Congress. “Since I’m running for governor, this is not the kind of thing you’d see in a Cuccinelli governorship.”

Cuccinelli accused McAuliffe of threatening a budget showdown of his own, based on McAuliffe’s statement at several campaign appearances that he would not sign a budget unless it expanded Medicaid.

“You’ve heard over and over here tonight on how this is his major funding mechanism for doing everything he wants to do,” Cuccinelli said. “This is not an appropriate tactic.”

Then he added: “If you like the way Washington works, you will like Governor McAuliffe.”

Neither candidate took a position on one of the more surprising questions from moderator Chuck Todd, chief White House correspondent for NBC News: Whether the Washington Redskins should change the team’s name because some people find it offensive. In a rare moment of agreement, both men said it was not their place to tell a private enterprise what to call itself.

The candidates opened the forum with endearing biographical details. Cuccinelli recalled a grandfather who worked in a scrap yard and as a “bare-knuckle boxer.” McAuliffe, often derided as a carpetbagger, noted that he and his wife have lived in McLean for two decades and raised five children there.

The debate, sponsored by the Fairfax County Chamber of Commerce and NBC4 Washington at the Capital One Conference Center, was a high-stakes appearance for both candidates in a state that has tended to choose middle-of-the-road governors.

The only competitive governor’s race in the country this year, the contest has drawn national attention and millions in out-of-state funding.

McAuliffe leads by 47 percent to 39 percent among likely voters, according to a Washington Post poll released this week, which also put Libertarian Party candidate Robert Sarvis at 10 percent. It was a tighter race, 49 percent to 44 percent, between McAuliffe and Cuccinelli without Sarvis in the mix, the poll found.

Sarvis was not included in the debate but attended to draw attention to his exclusion. He said he hopes to be included in the next debate, at Virginia Tech on Oct. 24.

“It would be much better with me in it,” Sarvis said. “It would be more substantive, less negative. I’d be talking issues.”

Mark Berman and Paul Schwartzman contributed to this report.