The Supreme Court ruled 6 to 3 yesterday that a New York State law to reimburse 2,000 religious schools for state-ordered record-keeping and testing services violates the Constitution.

The law "will of necessity either have the primary effect of aiding religion, or will result in excessive state involvement in religious affairs," Justice Poter Stewart wrote in the opinion for the court.

In a one-sentence dissent, Justice Bryon R. White accused the majority of continuing "to misconsture the First Amendment in a manner that discriminates against religion and is contrary to the fundamental educational needs of the country."

The case dates back to 1970, when the state legislature enacted a law to reimburse non-public schools for performing required record-keeping and testing services.

In 1972, a three-judge federal panel ruled the law unconstitutional and issued an injunction barring the state from making payments under it. The prohibition specifically included payments for expenses "heretofore" incurred in the 1971-1972 school year. The Supreme Court affirmed the ruling.

Citing "a moral obligation" to the schools, the legislature then anacted a substitute law to allow reimbursements only for the 1971-1972 school year. The sum involved exceeded $11 million.

The New York Court of Appeals upheld the substitute law. Yesterday, Chief Justice Warren E. Burger and Justice William H. Renhquist said in a dissent that they would have affirmed the New York tribunal.

In the Supreme Court opinion reversing the lower tribunal, Justice Stewart said that to validate the law would be tantamount to saying that a legislature can modify a federal court injunction "whenever a balancing of constitutional equities might conceivably have justified the court's granting similar relief in the first place."

"This rule would mean that every unconstitutional statue, like every dog, gets one bite, if anyone had relied on the statute to his detriment," Stewart added.