Virginia legislators, bowing to a threatened cut in federal highway funds, gave final approval today to a bill raising the state's beer-drinking age from 19 to 21 by 1987.

The House of Delegates overwhelmingly approved a Senate bill that will increase the age in two steps after rejecting by a vote of 62 to 27 an attempt to delay any state action on the issue until Congress raises the drinking age on military bases to 21.

The measure, which goes to Gov. Charles S. Robb for his signature, would increase the age to 20 in July 1986, and then to 21 in July 1987. Robb, who has said he supported the higher age since 1982, is expected to sign the bill.

State Sen. Richard L. Saslaw (D-Fairfax), who sponsored the bill, said its graduated implementation means no one would be allowed to drink under current law and then lose the right as the higher age becomes effective.

The action will make Virginia's drinking age the same as Maryland's. The District, however, allows the sale of beer and light wine to 18-year-olds, and efforts to raise the drinking age there have encountered strong opposition from Washington's restaurant and bar owners. There is no legislation pending before the D.C. City Council to raise the drinking age. All three jurisdictions prohibit sale of hard liquor to those under 21.

The Virginia legislature's action today follows four years of intense debate over how the rights of the young stacked up against saving lives on the highways. The debate became academic last year after the federal government said it would cut 10 percent of federal highway funds to states that did not enact the higher age by 1986.

"I think it came down to resignation to the fact that it was time to quit screwing around with this," said Del. Frank D. Hargrove (R-Hanover), an advocate of the higher age.

While opponents conceded the inevitability of setting the drinking age at 21, they attempted to forestall it for another year as a protest of what they said was the federal government's hypocrisy in not enforcing a similar rule on military bases.

Del. Theodore V. Morrison Jr. (D-Newport News) led the effort to pressure Congress for a rule against drinking by those under 21 on military property. "This is one year we've got a chance to send a message . . . and hope other states will join us," he said.

Supporters of the higher age, including Del. Ralph L. Axselle (D-Henrico), argued that the objection to drinking on military bases was "a subterfuge" by legislators who simply didn't like the bill. Axselle quoted a Defense Department memorandum stating that military bases are required to conform to the drinking-age law of the state in which they are located.

Supporters credited heavy, last-minute lobbying by the governor's office and a group of 10 delegates with defeating a last push for what one legislator called "the nose-tweaking amendment" today. Axselle said legislators also took today's vote "more seriously" than earlier votes because "they realized this was the real show."

Though the state could wait another year without jeopardizing any federal highway money, supporters argued vehemently against any more delays. "We need to address this problem today," said Hargrove. "Let's get it out of here and be done with it. If we save just one life, then we have done the right thing."

"We're sitting around telling Congress some little message," said Del. Ford C. Quillen (D-Scott), "and we're losing all this money. If we're going to have a national, uniform drinking age, I think it would be absurd for us to lag behind."

Del. Mary Sue Terry (D-Stuart), said the legislature would be forced to put the higher drinking age into effect "cold turkey" next year if it did not act this year. Supporters estimate that Virginia stood to lose an estimated $12 million in highway funds in 1987 and $28 million in 1988 if it did not change the age.