The D.C. Court of Appeals, ruling that child custody decisions cannot be made solely on the basis of race, has overturned a Superior Court ruling that removed a black child from the custody of white foster parents and placed her with her natural grandparents.

A three-judge panel of the appellate court ruled 2 to 1 that a custody decision that leans too heavily on race represents "an impermissible intellectual shortcut" and that other factors, such as family income, stability and affection, must be taken into account.

The court also rejected the contention by the white couple, who continue to maintain custody of the child, that a city law allowing race to be considered as a factor in adoption is unconstitutional. But it called that law vague, and said the lower court had failed to examine in enough detail the particulars of the case at hand.

D.C. government psychiatrists and social workers had recommended in the original custody trial that the grandparents be given custody of the child so that she later would not be confused about her identity or stigmatized.

Writing for the appeals court majority in the decision handed down Wednesday, Judge John M. Ferren wrote that "a presumption based solely upon the race of competing sets of would-be parents has no place in adoption proceedings."

Ferren also stated that city law on the subject fails to spell out how such factors as race and religion should be weighed in custody decisions.

Chief Judge Theodore R. Newman was the lone dissenter on the panel, writing that placement with the grandparents was in the girl's best interest "since black children in interracial families may be even more exposed to racist attitudes than other blacks."

Newman wrote of such children that "their need for survival skills is more acute. White parents, however, tend to be less equipped to pass on those skills." The chief judge added that it was "unrealistic to blind ourselves to color in such instances."

None of the principals in the case was named in court records, in order to protect the identity of the child. As a result of the appeals court's ruling, the custody issue must now be reconsidered in Superior Court.

Attorneys for the white foster parents, described only as an Army major and his wife who live on an Army base on the East Coast, hailed the ruling.

"Just because a child happens to be black, how do you tip the scales to parents who are the same color?" asked one of the lawyers, Bobby B. Stafford.

Banjamin F. Saulter, attorney for the grandparents, said: "We weren't saying that they the foster parents were not appropriate. But given the two alternatives, the child would be more comfortable with her genetic family."

The girl was 2 years old when her adoption case was heard in 1979 by Judge William C. Pryor, then a judge of the Superior Court, who now sits on the appeals court but did not participate in this week's decision. Although the adoption is still not finally decided, the white couple continues to maintain custody under a stay of Pryor's order issued by the appeals court.

The adoption became an issue when the girl was just a few months old, according to the 71-page appeals court decision. She was born to two black, unwed teen-agers. The father lived in Cleveland, the mother in Washington.

The mother relinquished custody of the girl to the city's social service apparatus, then called the Department of Human Resources. The city offered her for adoption to the white couple, then living on an Army base in suburban Washington. The couple received custody of the child, pending completion of formal adoption procedures court. The foster mother insisted that the girl's father be informed of the adoption. When he was, he contacted his parents, who also filed for adoption.

City social workers reviewed conditions in both families and recommended the girl be placed with the grandparents, who live in Northeast Washington. The competing adoption petitions then went before Judge Pryor.

At trial, a psychiatrist testifying for the city said, according to the appellate decision, "that cross-racial adoption always will be harmful to a child and--at the very least--should be discouraged."

The white foster mother told the court that at the time she was caring for another black adopted child. "I make sure he knows that he's not white," she testified. "I don't care how long he lives with us, he's black, and he's beautiful, and he's ours."