SAN FRANCISCO — The California Supreme Court ruled that two felony convictions stemming from a single act cannot be counted as separate strikes under the state’s three strikes sentencing law.

The 1994 law requires the doubling of a sentence if a defendant has a prior qualifying felony conviction, and that the person be given a life term if there are two such convictions.

The unanimous ruling on Thursday came in the case of Darlene Vargas, who was sentenced to 25-years to life for burglary on the basis of two prior convictions.

The high court said those convictions for robbery and carjacking stemmed from the same act — taking a car by force — and should not count as two separate strikes and prompt a tougher sentence.

Writing for the court, Justice Kathryn Mickle Werdegar said the case presented an extreme situation in which the convictions were based on the “same act, committed at the same time against the same victim.”

Werdegar said treating Vargas’ convictions as two separate strikes was inconsistent with the spirit of the three strikes law.

“The voting public would reasonably have understood the three strikes baseball metaphor to mean that a person would have three chances — three swings of the bat, if you will — before the harshest penalty could be imposed,” she said. “The public also would have understood that no one can be called for two strikes on just one swing.”

The justices sent the case back to the trial court for resentencing.