PORTLAND — Maine’s highest court has ruled that the state must repay taxes it collected from a Massachusetts man for bringing his plane to Maine on visits.

The Maine Supreme Judicial Court ruled Tuesday the state was wrong to send the $26,000 bill to Steve Kahn of Bedford, Mass. Maine tax officials said the law allowed them to collect a 5 percent “use tax” from out-of-state residents if they didn’t pay sales taxes on planes they bought elsewhere but flew to Maine during the first year they owned the planes.

In Kahn’s case, the court said the plane should be exempt from the tax because it was in Maine for only 6 or 7 percent of the year in question, which wasn’t enough to justify the tax.