A federal judge yesterday struck down the Reagan administration's controversial "Baby Doe" rule, calling it an "arbitrary and capricious agency action" that would disrupt the medical care of handicapped infants.

In a ruling that applies nationally, U.S. District Court Judge Gerhard A. Gesell said that the regulation, which sought to protect babies born with serious birth defects from being denied food or medical treatment, was a "hasty and ill-considered" response to "one of the most difficult and sensitive medical and ethical problems facing our society."

The decision was a major victory for medical groups that argued the controversial rule "directly injected the federal government into the hospital and parent-doctor relationship."

The Reagan administration, prodded by right-to-life groups, had used a novel application of a civil rights law protecting the handicapped to justify the rule. It required that hospitals receiving federal aid post warning notices that such discrimination is subject to prosecution, including a loss of federal funding, and set up a toll-free hotline to take anonymous complaints from across the country.

Government lawyers yesterday unsuccessfully sought to stay Gesell's decision. Health and Human Services Secretary Margaret M. Heckler issued a statement saying that "this administration remains determined to protect the lives of handicapped infants and to assure them their equal right to be given appropriate medical care and nourishment. We intend to file an immediate appeal."

Gesell voided the regulation on procedural grounds, finding that the government, in issuing the rule on an emergency basis effective March 22, violated a law requiring time for the public to comment before a rule of such magnitude is issued.

But he strongly criticized the administration on a broader basis for taking "no consideration whatsoever of the disruptive effects" of issuing a rule that would set up a a "hotline informer" system in hospitals. He also invoked the image of the "sudden descent of 'Baby Doe' squads on the scene" while doctors are trying to make medical treatment decisions.

Noting that "there may well be defects in medical procedures and hospital policies governing treatment of seriously disabled newborns in some hospitals," Gesell concluded that the government's rule "can hardly be presumed to produce higher quality care for the infant."

The American Academy of Pediatrics, the 24,000-member doctors' group which filed the lawsuit, said it was "very gratified with the court's decision, which strongly supports its view that the HHS rule would not have been in the best interests of handicapped infants."

The academy was joined in the suit by the National Association of Children's Hospitals and locally by the Children's Hospital National Medical Center. Children's Hospital Director Dr. Robert Parrott said the ruling would keep medical decision-making in the hands of "parents and the professional health care team who are deeply involved in that care."

Offering an olive branch to the administration, the pediatrics group said that "we look forward now to cooperating with the HHS secretary or her designate to find a better way to solve this very sensitive problem."

The medical groups say they share the administration's concerns about children, including the handling of the highly publicized "Baby Doe" case in Indiana last April that was the springboard for the government's action. The case involved withholding food and treatment from a baby at the request of his parents, doctors and the state's highest court. The infant was born with multiple problems, including Down's syndrome, a condition that leads to mental retardation.

Attorney Tom Fox, representing the medical groups, argued that the judge gave "several warnings" about the larger constitutional and legislative issues, suggesting that "even if they are able to satisfy the procedural requirements, the government could not come out and justify a rule such as this."