RICHMOND, FEB. 29 -- Virginia Democratic Lt. Gov. L. Douglas Wilder, with the help of the Senate's minority Republicans, scored a political coup today when his proposal to eliminate the sales tax on nonprescription drugs was approved over the protests of the Senate's Democratic leadership.

Wilder's bill, a key component of his expected bid for governor next year, was consigned to oblivion this month by Senate Majority Leader Hunter B. Andrews (D-Hampton), who, in his role as chairman of the Finance Committee, refused to allow it to be put to a vote.

So today Wilder and his supporters brought the idea to the floor as an amendment to an unrelated bill that had passed the House of Delegates.

The maneuver caught the leadership off guard, and before they could galvanize opposition or stall, the amended bill was passed, 24 to 15. All but one of the chamber's 10 Republicans joined half of the body's Democrats in a rare bipartisan victory.

Wilder said the vote showed there is a "collective, bipartisan will" to offer tax relief. The action "speaks to an issue, not to ideology or party or personality. If a thing is right, the time is right," he said, repeating one of his favorite slogans.

Sen. Dudley J. (Buzz) Emick Jr. (D-Botetourt), who sponsored the tax cut legislation for Wilder, joined forces with Republican Sen. Wiley F. Mitchell Jr. of Alexandria, whose own tax-cutting idea -- to use profits from the soon-to-be-operating state lottery to eliminate the sales tax on food -- had been summarily rejected by the finance panel.

Today's compromise incorporated Mitchell's financing plan, setting aside $15 million to $20 million a year in lottery profits to offset the cost of Wilder's less ambitious plan to eliminate the sales tax on nonprescription drugs. The measure would not take effect until June 30, 1989, by which time the lottery will have been in operation about a year.

Emick credited Sen. Richard L. Saslaw (D-Springfield) for thinking of the complicated parliamentary maneuver that forced a vote on the amendment before its opponents could seek to delay the vote overnight to give them time to round up the votes to defeat it.

"It was legislation by ambush," protested Sen. Joseph V. Gartlan Jr. (D-Mount Vernon), an Andrews ally who, like other members of the leadership, did not know about the plan, hatched over the weekend, until moments before it was put to a vote.

Andrews, a master tactician himself, did not cry foul. "Everything is fair in this game," he said, adding that he opposed the idea because it "appropriates money {lottery profits} before it exists."

"I don't think it is a slap at anyone," said Wilder, even while pointing out that five of the 15 members of the Senate Finance Committee supported it, and a sixth declined to vote. Ordinarily, Finance Committee members follow a unit rule on issues they have previously considered, and vote in a bloc, even if they were on the losing side in committee.

As to whether the unusual bipartisan, rural-urban alliance might unite again before the session ends a week from Saturday, Mitchell said that "one swallow does not make a spring, but this does reflect the potential" of a majority of senators to work together. But he added that no deals for the future were struck, and "nobody owes anyone anything."

Wilder's victory may be short-lived because the revised bill will be returned to the House, where Speaker A.L. Philpott (D-Bassett), grumbling that he had "never heard of such a thing," predicted it would be rejected.

A stalemate would result in the appointment of a conference committee of senators and delegates, who would try to work out a compromise. Another possibility is that the House will retaliate by putting its original proposal, which changes the method of taxing telephone companies, on a bill wanted by the Senate.

"It shows the lieutenant governor has some political clout," said House Finance Committee Chairman C. Richard Cranwell (D-Vinton), who had announced that he had struck a deal with Andrews so that no exemptions to the sales tax would be considered this year.