Virginia officials illegally denied Medicaid payments to hundreds--perhaps thousands--of elderly persons who were disqualified under a recently contested state regulation that stayed in effect for 12 years, a federal judge has ruled.

The regulation, struck down by U.S. District Court Judge James C. Turk, prohibited applicants from receiving Medicaid assistance for one year if they gave away excess assets, such as land holdings, to their children, relatives or others. It also barred Medicaid payments if the assets were sold for less than their fair market value.

State officials say the regulation, in effect from 1969 to last July 1, was intended to prevent abuses by middle- and high-income persons who might seek to qualify for government-financed medical assistance by giving away valuable property to their relatives. Medicaid is aimed at providing health care for the poor.

Legal Aid Society lawyers in Charlottesville challenged the regulation in behalf of eight elderly or disabled persons of modest means, including an Arlington woman, Evelyn L. Randall, then living in a Woodbridge nursing home. The class-action suit argued that the rule improperly denied Medicaid to needy Virginians who merely wished to pass on land or other property to their children.

Turk, a Roanoke judge, held that the state-imposed restriction was not permitted under federal Medicaid laws at the time. Similar state regulations have recently been overturned by U.S. judges in Illinois, Mississippi, New York and elsewhere. In his ruling last Friday Turk asserted, however, that Congress' failure to authorize such rules left an "unfortunate loophole" in the Medicaid program.

In December 1980, Congress enacted a measure that authorized states to impose such "transfer of assets" restrictions on Medicaid payments. Virginia health officials then adopted a new regulation, effective last July 1, barring Medicaid for at least two years, rather than one year, to applicants who transfer their excess assets. Turk upheld the new Virginia regulation, citing Congress' move.

How much money Medicaid applicants who were denied assistance under the former Virginia regulation may now recover is in dispute. Assistant Virginia Attorney General Robert T. Adams said yesterday that no such payments are allowed under state rules because too much time has elapsed to file claims. Legal Aid lawyer Herbert L. Beskin disagreed, citing federal regulations.

Turk's order, which Adams said the state plans to appeal, requires Virginia officials to notify Medicaid applicants that they were improperly denied benefits, but it leaves to the state to determine what claims must be paid.