The Supreme Court, reaffirming in strong terms its prior decisions on the constitutional separation of church and state, ruled yesterday that public funds may not be used to pay for teachers in religious schools.

A narrow 5-to-4 majority struck down both New York City's use of federal remedial education funds for teachers in church-related schools and the use of state funds in Grand Rapids, Mich., for teaching remedial and enrichment courses in parochial schools. The rulings were a defeat for some religious groups advocating aid to parochial schools and for the Reagan administration, which urged the court to approve the aid.

The rulings, the most important of several this term on church-state issues, contrast with decisions in the last three years in which the court appeared to be willing to allow significant breaches in the "wall" separating church and state.

But the majority yesterday, and in decisions last month involving Sabbath work laws and school prayer, made clear that the court is unlikely to go much further in allowing accommodation of religious needs.

"Lines must be drawn," Justice William J. Brennan Jr. wrote for the majority in both cases yesterday. Brennan repeatedly cited the court's decisions from the early 1970s that generally struck down or, at most, gave grudging assistance to parochial schools.

"The controlling constitutional standards have become firmly rooted," Brennan added in the Grand Rapids case.

New York's program is part of the massive federal Title I grant of funds for sending public school teachers into religious schools to teach remedial math and English to economically disadvantaged, mostly inner-city children.

About $120 million of the federal program's $3 billion annual budget goes to religious school students. About 13 percent of $147 million New York received in 1982 went to assist religious schools with 84 percent of that to Roman Catholic schools, 8 percent to Jewish schools and the remainder to other groups.

In Grand Rapids, about 11,000 children in 40 Catholic, Christian Reformed, Lutheran and other religious schools -- one-third of the city's school-age population -- were being taught part time until 1982 by public school teachers at public expense. The subjects taught ranged from remedial and advanced math and reading to languages, social studies, art and music.

School officials in both cities, mindful of possible constitutional objections to the programs, took down or covered religious symbols in the taxpayer-funded classes and, in Grand Rapids, even had the public school system pay rent to show public control over the space.

New York City officials, which urged the court to uphold their program, argued that they, unlike Grand Rapids, had a strict monitoring system to ensure that Title I-funded teachers did not teach religion.

New York parochial school officials yesterday said they were not sure what programs would now be acceptable, but classes off-site, either in trailers or by busing students to public schools, probably would be upheld.

The Grand Rapids program had ended in 1982 after a judge struck it down. Albert Dilley, an attorney for the Grand Rapids taxpayers, said yesterday's ruling would end similar programs in about 19 other locations in Michigan.

Most court observers had expected the more open-ended Grand Rapids program to have a difficult time passing constitutional muster. But even civil liberties lawyers were surprised yesterday when the court struck down the popular New York program.

New York's argument "fails in any event," Brennan wrote, "because the supervisory system established by the city of New York inevitably results in the excessive entanglement of church and state."

"Despite the well-intentioned efforts taken by the city of New York," Brennan said, "the program remains constitutionally flawed owing to the nature of the aid, the institution receiving the aid and the constitutional principles that they implicate -- that neither the state nor federal government shall promote or hinder a particular faith or faith generally through the advancement of benefits or through excessive entanglement of church and state in the administration of those benefits."

Justice Lewis F. Powell Jr., author of an opinion two years ago allowing tax deductions in Minnesota for parents of parochial school children, provided the critical fifth vote for the majority yesterday.

Powell wrote a concurring opinion to say why the court was obliged to "invalidate these two educational programs that concededly have done so much good and little, if any, detectable harm."

Powell said the "risk of entanglement is compounded by the additional risk of political divisiveness stemming from the aid to religion here." He said "there remains a considerable risk of continuing political strife over the propriety of direct aid to religious schools and the proper allocation of limited governmental resources . . . and frequently strain a political system to the breaking point."

Powell said indirect aid would still be upheld, but direct aid such as that in New York and Grand Rapids could not stand.

Brennan's opinion also was joined by Justices Thurgood Marshall, Harry A. Blackmun and John Paul Stevens. All five justices in the majority, except for Stevens, were in the majority 10 years ago when the court struck down a similar program of aid to religious schools.

Chief Justice Warren E. Burger dissented yesterday for the same reasons he gave in his dissent in that same case 10 years ago. "What is disconcerting about the result reached today is that, in the face of the human cost entailed by this decision," Burger wrote in the New York case, "the court does not even attempt to identify any threat to religious liberty posed by the operation of Title I.

"It borders on paranoia to perceive the Archbishop of Canterbury or the Bishop of Rome lurking behind programs that are just as vital to the nation's schoolchildren as textbooks" and other forms of aid previously approved.

Justices Byron R. White, William H. Rehnquist and Sandra Day O'Connor also dissented yesterday.

Rehnquist, citing the court's recent cases approving a city-sponsored Christmas nativity scene and a state-paid legislative chaplain in Nebraska, said, "One wonders how the teaching of mathematics, Spanish and gymnastics which is struck down today, creates a greater symbolic link" between church and state than those cases.

"A most unfortunate result of Grand Rapids is that to support its holding the court, despite its disclaimers, impugns the integrity of public school teachers. Contrary to the law and the teachers' promises, there are assumed to be eager inculcators of religious dogma requiring, in the court's words, 'ongoing supervision.'

"Not one instance of attempted religious inculcation exists in the records of the school aid cases decided today, even though both the Grand Rapids and New York programs have been in operation for a number of years," he said.

The issues decided yesterday had split various Protestant and Jewish groups, while Catholic organizations had strongly supported the New York program.

The American Jewish Committee, for example, joined the National Council of Churches and a Baptist group against the Grand Rapids program. The committee issued a statement yesterday praising the court's ruling in the Grand Rapids case, but had no comment on the New York case because the organization decided not to take a formal position regarding that program for disadvantaged children.

Another Jewish group had entered the case in favor of the New York program while the American Jewish Congress opposed both programs.

The Rev. James Kearney, superintendent of schools for the Archdiocese of New York, said the "decision was a blow to fairness and justice for poor and needy children in public as well as nonpublic schools.

"By not allowing on-site neutral service, needy nonpublic schoolchildren have been deprived of the same right to federally funded services that public schoolchildren have -- merely because their parents have exercised their right of choice in the education of their children. This is fundamentally unfair to those children who need the help most."

A Justice Department spokesman said the department "wished the court had accepted the provision we advanced in these two cases. We will continue to argue in the courts on behalf of those government programs that we believe accommodate religious beliefs . . . but do not also establish a religion."

University of Virginia Law School Prof. A.E. Dick Howard, who argued the case for the Michigan taxpayers, said the opinion, with four of the five justices in the majority over 76 years old, was "not written in stone."

"But the more opinions the court hands down at this time" involving separation of church and state, the more difficult it will be for a new set of justices "to throw out the line of precedent."