U.S. Sen. Barbara Boxer and former Hewlett-Packard CEO Carly Fiorina clashed Wednesday night in a hard-hitting debate that highlighted their sharp ideological differences on a range of fiscal and social issues — from jobs and the environment to abortion and gun rights.

Fiorina found herself on the defensive for much of the hourlong debate, faced with repeated questions about her conservative views. Fiorina was forced to answer for the decidedly right-of-center positions she took during the Republican primary, and she did not back away, saying that she would vote to overturn Roe v. Wade “if there were an opportunity” and calling the assault weapons ban “arbitrary.” Fiorina also had to defend her statement from the primary race that people on the government no-fly list should be allowed to purchase guns and an ad in which she likened global warming to “the weather.”

Her answers allowed Boxer to press the case, over and over, that Fiorina is out of step with the California electorate.

“This is a very clear choice,” Boxer said, reciting a litany of Fiorina’s statements she called extreme.

Fiorina lodged the same charge against Boxer, depicting her as a staunch partisan with a thin legislative record and far-left views, particularly on the economy and government spending.

“Her record is long on talk and very short on achievement, and the reason it is short is because she is one of the most bitterly partisan members of the U.S. Senate.”

Bruce Cain, a UC Berkeley professor and director of the University of California Washington Center, said he was struck by how little Fiorina moderated the positions she took during the GOP primary. Often, candidates who woo the more partisan voters in a primary will run to the center in a general election in order to appeal to swing voters.

The debate made clear that Fiorina is having no part of that strategy.

“If Carly Fiorina wins taking the positions she’s taken, it would represent a sea change in how we think about California politics,” Cain said. “Conventional wisdom would be completely overthrown.”

While Fiorina came across as articulate and well-informed, Cain said, he thought Boxer won the debate.

“On balance, I think Barbara Boxer has to be pleased,” he said.

Boxer and Fiorina entered the night running neck-and-neck in the polls, with several Washington pundits declaring the race a tossup. Raising the stakes was the fact that it is, so far, the only scheduled debate between the two until the Nov. 2 election.

Fiorina criticized Boxer as a career politician — she is seeking a fourth six-year term in the Senate, after serving a decade in the House — who has consistently voted for higher taxes and more spending. But some of the debate’s livelier exchanges were about issues other than the economy.

After Fiorina answered a question about stem cell research, for instance, moderator Randy Shandobil of KTVU pressed her on whether she would vote to overturn Roe v. Wade.

She said first that she is anti-abortion in part because her husband’s mother was told to abort him. Asked again, she said she would vote to overturn it “if there were an opportunity; it is not something I am running on.” She added that she thinks the issue should be left in the hands of individual states.

“What the people of California have to understand is that if my opponent’s views prevailed, women and doctors would be criminals,” Boxer, a longtime vocal supporter of abortion rights, responded. “They would go to jail. And women would die like they did before Roe v. Wade.”

Shortly after, Fiorina was grilled on her views of AB 32, California’s major climate change bill, and whether she backs Prop. 23, a November ballot measure that would suspend the law.

After Fiorina dodged the question, Shandobil said, “Yes or no? Just answer, do you support it?”

“I have not taken a position on it yet,” Fiorina responded, adding that “there’s no question in my mind … that AB 32 is at the very least, in the short term, a job killer.”

Boxer retorted: “Well, if you can’t take a stand on Prop. 23, I don’t know what you will take a stand on.”

Boxer also relentlessly attacked Fiorina’s record at HP, noting that she laid off more than 30,000 workers and sent jobs overseas before being fired and receiving a $21 million severance package. Fiorina was asked whether the severance was warranted given her position that school teachers should be paid based on performance.

Fiorina said that she put her pay at HP up for a vote before the company’s board of directors and that “every dollar was tied very specifically to performance.”

The debate at Saint Mary’s College in Moraga was sponsored by KTVU-Channel 2, the San Francisco Chronicle and KQED Public Radio.