The bill would have repealed Virginia's sales tax on nonprescription drugs at a cost to the state of about $12 million a year -- a small sum considering the $184-million surplus sitting in the state treasury.

But Gov. John N. Dalton opposed it and his influential ally, Senate Finance Chairman Edward E. Willey, was determined to bury it.

"You gentlemen can't have it both ways," the white-haired septuagenarian sternly lectured his committee, as if addressing a group of recalcitrant schoolboys. "If you want to pass this bill, you're going to have to cut some programs . . . Let me know which ones."

That the committee effectively killed the bill at a recent session was a tribute not only to Willey's personal power but also to the longstanding alliance on money matters between the governor and a tightly knit group of conservative Democratic legislative leaders. While in most states a Republican governor and a Democratic-dominated legislature might be at each other's throats, in Virginia -- despite grumbling from the legislature's few liberals -- Dalton and the Democrats work together and keep a tight grip on the state budget.

"It's a good team effort," said Dalton through a spokesman. "While they are of the opposite party, I've always felt they put Virginia's best interests ahead of any partisan consideration."

The extent of the harmony will be tested this year by efforts of some Democrats to use the budget surplus for tax relief rather than spend it on state programs and salary increases as Dalton has requested. But many legislators believe that, despite the likelihood of extended debates on the issue, the fate of the surplus was actually settled weeks ago in a series of private meetings and phone calls between Dalton, his top finance expert Charles B. Walker, House Appropriations Chairman Richard M. Bagley of Hampton, and Willey.

When Dalton called together a group of the state's leading businessmen behind closed doors two months ago to offer their projections of tax revenues for the coming year and determine the size of the surplus, Willey and Bagley were honored guests. When the governor outlined in his opening legislative address last week just how he wanted to spend the surplus, Willey and Bagley were already aware of what he would say.

And should any tax-relief measure slip out of the election-conscious House of Delegates, Dalton can count on Willey to handle it the same way the gruff, retired Richmond pharmacist dispatched the nonprescription drug bill.

"I'm a realist," says Willey, "and the facts of life are you can't fund all these state services and cut taxes at the same time."

Some Democrats believe that the cooperative effort between the leadership and Dalton benefits the governor while contibuting to their party's decline in Virginia. In their view, Dalton gets credit for a conservative budget-cutting image while the legislative Democrats are left with a largely anonymous role.

"They're letting Dalton have his cake and eat it, too," says Democrat Paul Goldman. "He gets to pose as the great fiscal conservative, while at the same time he gets them to kil any tax-cut bills he doesn't want."

Neither Willey nor Bagley agrees. Both see it as their obligation, indeed as an almost sacred duty, to help Dalton maintain Virginia's balanced, conservative budget.

"It's always been like this," says the scholarly, pipe-smoking Bagley, who owns an investment firm but works full time at his part-time legislative job. "It might have blown apart with [former governor] Linwood Holton, who had never served a day in the legislature and didn't even know where the governor's office was when he took over, but it didn't."

Bagley has a special interest in helping Dalton, a close friend who entered the House of Delegates in 1966, the same year as Bagley, Both men toiled on the Appropriations Committee together, and Bagley estimates he talks to the governor at least once a week. Bagley was also one of those who recommended the appointment of Walker, Dalton's secretary of administration and finance and the man who is the key link between Dalton and the committee chairmen.

Walker or his top aide attend every meeting of Willey's and Bagley's committees and is always available to handle questions and problems as they arise . While Walker's manner is always deferential, his facts are considered virtually unchallengeable. The net result, say some lawmakers, is that the budget Walker and his staff work up is seldom questioned or revised in any major way by the legislators.

"Dick Bagley's a wonderful man, but what happens is you sit up there as chairman of a powerful committee and every bureaucrat kises your tush, and you wind up relying on them for information and advice," sayd Del. Warren G. Stambaugh (D-Arlington), a tax-cut advocate. "I's not too long before you become more sensitive to the needs of state agencies than to the needs of people."

Even those who agree with Walker and Bagley concede they sometimes feel they have little choice. "Even when we make a change, you get the feeling it's all been rehearsed for us in advance," says Del. Warren Barry (R-Fairfax), an Appropriations Committee member.

While Willey's relationship with Dalton is more formal than Bagley's, he still feels a close kinship. Willey helped steer Dalton's statewide gasoline-tax increase through a reluctant legislature last year by forcing some key Northern Virginia lawmakers to vote for the bill under threat that he would kill a Metro funding proposal if they refused to cooperate. Some Northern Virginians cried blackmail -- but relented.