PORTLAND —The minimum prison sentences mandated by Tina’s Law, which aims to crack down on dangerous drivers, are constitutional, Maine’s highest court ruled Tuesday.

The Maine Supreme Judicial Court’s unanimous ruling upheld the sentencing provisions of the law and vacated the sentence of a Vietnam War veteran who was convicted of continuing to drive after losing his license as a habitual offender.

In December 2008, Superior Court Justice Michaela Murphy sentenced Gerald Gilman to 90 days in jail, calling the two-year minimum in the law unconstitutionally harsh in Gilman’s case.

But the Supreme Court justices agreed with prosecutors, who said Murphy’s sentence was illegal. Gilman must return to court and be resentenced.

Gilman was stopped for speeding in his hometown of New Sharon in April 2007. He was later convicted of driving after license revocation, with the charge enhanced because he had three drunken-driving convictions in the previous 10 years.

Under Tina’s Law, which created the crime of aggravated operating after habitual offender revocation, Gilman faced a mandatory sentence of at least two years.

The law, enacted in 2006, is named for Tina Turcotte, who died of injuries she suffered in a highway crash caused by a trucker who had a long record of offenses.

Gilman’s lawyer, Woody Hanstein, argued successfully before Murphy that a two-year sentence was unconstitutional in Gilman’s case. Hanstein said Gilman had served his country, had given up drinking, had sought help for his post-traumatic stress disorder and was connecting with other veterans.

Murphy agreed, writing that a two-year sentence “would be greatly disproportionate to the offense, and also that it would offend prevailing notions of decency.”

In their ruling Tuesday, Supreme Court justices wrote that when the Legislature establishes a mandatory minimum sentence for a crime, the sentencing court cannot use mitigating factors to justify a lesser sentence.

Hanstein said it was “courageous” for the judge to give Gilman a lighter sentence than what was mandated. It’s a travesty, he said, to send Gilman to prison for two years.

“It’s just absolutely a waste of human life and taxpayers’ money,” he said.

Prosecutors with the Franklin County District Attorney’s Office were not available for comment.

The Supreme Court’s decision came a day after U.S. Reps. Mike Michaud and Chellie Pingree announced that they had recommended Murphy to replace U.S. District Judge D. Brock Hornby on the federal bench.