Native American issues rarely reach the supreme court, and it is even rarer for the court to side with the tribes. Photograph: Kevin Lamarque/Reuters

Native American tribes are celebrating a major victory in their battle for equal treatment after the US supreme court ruled that the government could no longer short-change them over contracts for public services.

In a ruling announced on Monday, the justices sided 5-4 with the tribes, who had taken out a class action suit complaining that they were being treated unfairly by the department of the interior.

The suit claimed that the government had over many years withheld millions of dollars owed to the tribes by imposing a cap on the contracts it had taken out with them.

Native American leaders hailed the ruling as an important victory. Rodger Martinez, president of the Ramah Navajo Chapter in New Mexico that was a plaintiff in the case, said they had been saddened that they had to go all the way to the supreme court to find redress.

"But we are happy that they sided with us. This gets us back to the principle that the government must pay us what we are entitled to," he said.

The dispute over money relates to services provided by the tribes themselves under the Indian Self-Determination Act of 1975. Under that law, the tribes would sub-contract from the federal government public services such as police, schools, fire prevention, hospitals, and infrastructure works, as well as environmental works and subsidies to farmers.

Under the arrangement, the federal government would pay the tribes for the services provided, just as it would any other contractor. But from 1994 the government changed the way it paid for the services, no longer paying for each contract in full but handing the tribes a collective lump sum onto which it imposed a ceiling – thereby withholding from them a portion of the moneys owed.

The supreme court ruling found this to be unacceptable. "Consistent with longstanding principles of government contracting law, we hold that the government must pay each tribe's contract support costs in full," wrote justice Sonya Sotomayor, delivering the court's opinion.

The court split by a conventional 5-4, but did so along unconventional lines. Sotomayor was supported in the majority by the progressive justice Elena Kagan, and by the conservatives Antonin Scalia and Clarence Thomas, as well as the traditional swing voter Anthony Kennedy.

The minority combined the chief justice John Roberts and Samuel Alito with the more liberal Ruth Bader Ginsburg and Stephen Breyer.

Jonathan Cohn of the Washington-based law firm Sidley Austin, who jointly represented the tribes, said the judgment was a "big victory for the tribes. The government must fulfill its commitments and ensure the tribes get paid."

Cohn said that it was rare for Native American issues to reach the supreme court, and even rarer for the court to side with the tribes. At the heart of the case, he added, was the principle of equal treatment.

"The government was trying to treat tribal contractors differently from all other contractors. If you were talking about a defence contractor, I don't think this case would have reached the supreme court – the government would have paid up long ago."