The Maryland Court of Special Appeals ruled yesterday that a three-year-old boy should be returned to the custody of his natural mother despite the fact that he has been living with a foster family in Montgomery county for the last two years.

The state's second highest court explicity rejected the widely debated theory that the length of a child's separation from his natural parents should be the most important factor in determining whether the child should be returned to live with them.

The decision, written by Chief Judge Richard P. Gilbert, could have far-reaching implications for future child-custody cases in Maryland, according to one of the attorneys involved in the case.

Even though the court specifically limited its decision to the case of this three-year-old boy, the ruling set forth 10 specific criteria which judges in custody cases should weigh when making their decision. Those criteria provide the most specific guidelines issued to date on how to evaluate custody cases, attorney Gerald Tietz noted.

When weighing these factors, "the court should examine the totality of the situation in the alternative environments and avoid focusing on any single factor such as the financial situation. . . or the length of separation," Gilbert's opinion said.

The decision is not binding on Maryland courts unless it is appealed and then reaffirmed by the Court of Appeals. Maryland's highest court. An attorney for the social services department said yesterday that no decision had been made on whether to appeal the ruling, however.

The Montgomery County Department of Social Services, the child's father and the attorney appointed by the court to represent the three-year-old all had contended before the courts that the boy's foster family was the only family he knew, and that separation from it would result in severe emotional trauma.

This contention was based, according to the court opinion, on a theory developed by Anna Freud and two Yale University psychologists. that theory holds that "separation from the natural parent for a sufficient length of time (as little as two months) saps the bond of love and affection between child and parent, while simultaneously forging a strong psychological link which joins the child to a surrogate parent."

To break this new bond, according to the theory, would be unucessarily wrenching for the child and thus "detrimental to the child's best interests."

While the court opinion agreed that "the length of time apart is a factor to be considered in weighing the merits of each potential home," Judge Gilbert noted earlier that "custody cases involve too many people, conditions and human emotions to be reduced summarily to a mere mathematical process."

Also, the opinion said, even though the child's natural mother, has had "severe financial problems" and that the child "is now in a home offering superior material advantages," this does not mean that the three-year-old should be kept from his natural mother.

"The fact that parents are poor is not itself a reason for placing a child in foster care," the opinion said.

The boy was taken from his parents at the age of 10 months after he was admitted to Walter Reed Army Hospital suffering from multiple fractures. According to the opinion, there wasn't any conclusive indication that the mother was the cause of any of the child's injuries. The mother and the father of the child have since separated.