Secretary John F. Lehman Jr. has ordered Navy bases to comply with local drinking-age laws, putting to rest objections voiced by some Virginia legislators to the state law raising the beer drinking age to 21.

The secretary's order, made public yesterday and effective June 1, will end a 12-year-old policy allowing the consumption of low-alcohol beer by those 17 and older on naval bases, despite state laws prohibiting such sales off the base.

The policy drew sharp protest during the 1985 Virginia General Assembly session from legislators who said the rule should be the same for military personnel and civilians. The discrepancy repeatedly threatened to derail efforts to raise the drinking age for beer from 19 to 21 in the state, which ranks second in the nation in the number of Navy and Marine Corps personnel.

Lawmakers eventually bowed to a threatened federal cut in highway funds and passed a bill that will raise the age to 20 by July 1986 and to 21 by July 1987. The state's age limit for wine and liquor is already 21.

Capt. J.B. Finklestein, a Navy spokesman, said the outcry in the Virginia legislature "had absolutely nothing to do with" Lehman's order, which followed a general Defense Department directive ordering compliance with state laws. Similar orders are expected from the Army and Air Force secretaries.

Finklestein described the order as a natural outgrowth of a 1984 federal law that threatens states with the loss of up to 10 percent of federal highway funds unless they adopt the 21 age limit by 1986. "It puts us in line with what the government is seeking from the states," he said.

The order for military bases will make the change in Virginia's law "more fair," said Del. Clinton Miller (R-Shenandoah), who opposed the higher age limit. "Equality demands it . . . . If you're going to do it for one class of citizens, you ought to do it equally for all classes."

Del. Glenn B. McClanan (D-Virginia Beach) said he was "very happy" that the federal government had changed its "hypocritical . . . dual standard. Mandating to the states that they abide by one standard or lose highway funds and then applying a different standard at bases they control is indeed unfair."

The Navy has required its bases to conform to local drinking age laws since 1973, but it made an exception for 3.2 beer, which has a lower alcohol content.

The new order allows exceptions in three circumstances: when a military base is within 50 miles or one hour's driving time of a state with a lower drinking age and a lower age limit on the base is determined to be in the interest of "the motor vehicle safety of the community," to foster morale on special occasions, and at bases in remote locations.

Major naval bases in the Tidewater area, close to North Carolina, may benefit from the first exception. North Carolina allows the consumption of beer and nonfortified wine at age 19. But McClanan and others say they expect that North Carolina will soon raise its drinking age.