The General Accounting Office has ruled that a key element of the Reagan administration's plan to award only 5,000 new National Institutes of Health research grants in fiscal 1985 -- instead of the 6,526 that Congress funded -- is "unlawful."

The complex GAO ruling, released yesterday by Sen. Lowell P. Weicker Jr. (R-Conn.) at a Senate Appropriations subcommittee hearing, supported the administration on some legal points, but nevertheless gave Weicker a new weapon in his fight to get all 6,526 grants awarded this year and another 6,500 awarded next year.

Several Weicker aides said that the ruling will put pressure on the Health and Human Services Department to award all the grants. Department officials, however, had no comment.

The GAO said that it would be unlawful for the administration to divert to future years the funds saved this year by the cuts. It also said that if the administration agreed not to stretch out the spending but then refused to spend the money, it would be impounding funds illegally. But so far, the GAO said, the administration's plan did not amount to an illegal impoundment.

Weicker warned NIH officials at the hearing that any official who manages the research funds in ways forbidden by the ruling "does so at their personal risk."

Under the law, he said, such an official is personally liable for the amount given out illegally and the GAO can move to seize his bank accounts, house, car and other property.

Weicker, along with Sens. Edward M. Kennedy (D-Mass.), Mark O. Hatfield (R-Ore.) and 30 other senators, plans to introduce legislation today directing NIH to award all 6,526 new grants.

The dispute over the research grants has been simmering for months. After Congress funded the grants last year, the administration announced it would award only 5,000 and use the leftover money to cover routine renewal costs for 646 of the grants in later years.

Administration statements repeatedly made clear that the cutback was based almost entirely on a desire to cut government spending rather than any assessment that the government should conduct less biomedical research.

In its opinion, the GAO said that since Congress did not specify 6,526 grants in the language of the fiscal 1985 appropriations bill itself, but only in related statements and reports, the figure is not necessarily legally binding.

But the GAO said that holding up some of the money for use next year would violate a statute -- the so-called Bona Fide Need Rule -- unless Congress had said the NIH could spend the funds in more than one year.

The GAO suggested that the administration could decide either to fund more new grants or to rescind excess funds it doesn't want to spend.