As the clock struck midnight, members of the House Appropriations Committee were frantically looking for $1.5 million to balance Virginia's budget without cutting the cherished local projects they had endorsed earlier in the evening.

Finally, Secretary of Administration and Finance Charles B. Walker, the state's No. 1 money expert, noted an obscure budget item called a "revenue deficiency reserve" -- $10 million held by the governor for special unbudgeted costs.

The committee was quick to take the hint. It slashed the reserve to $8.5 million, balanced the state's books, and emerged early this morning after a nine-hour marathon session with an $11.5 billion biennial state budget that closely resembles the one proposed last month by Gov. John N. Dalton.

The major difference is in elementary and secondary education spending, which the committee increased by about $32 million -- 2 percent above the $1.9 billion submitted by Dalton but far less than the $208 million extra requested by the state Board of Education.

Most of the increase will go to local school boards, which will receive an average of $1,075 per pupil in state aid next year, about 5 percent above the $1,027 requested by the governor.

In Northern Virginia, where educators were most critical of the Dalton budget, Fairfax County will receive an extra 2.5 million, Arlington $1.1 million, Alexandria $750,000, Loudoun $230,000, Prince William $800,000, Falls Church $90,000, and Fairfax City $80,000, according to preliminary estimates.

But the increases are unlikely to stem criticism. The Virginia Education Association has announced a mass lobbying effort Monday to persuade the House to restore more money for education.

"Education was our top priority and we did the best we could because there wasn't any money," said Del. Vincent F. Callahan (R.-Fairfax).

The committee struck $4 million from the $45 million in new prison construction proposed by Dalton. It voted to put off building one of the two new prisons he recommended while speeding up completion of the other. It also voted $1 million for community service programs for nonserious offenders -- a program Dalton rejected. Critics of the prison system see the program as a first step toward reducing Virginia's swollen prison population.

But much of last night's session was devoted to the traditional carving of pork-barrel projects, which, even in a state with a tight-fisted a reputation as Virginia's, are an important source of prestige and votes.

Some of the big winners included Newport News, which got an additional $3 million for a port facility, and Northern Virginia Community College, which received $1.3 million to purchase the Tyler School building for its Alexandria campus.

The budget bill now goes to the floor of the House, which is expected to vote on it next Thursday. After that, the bill goes to the state Senate, which will tack on its own amendments, then haggle in a joint conference session over the final bill, which is usually not hammered out until just before the General Assembly adjourns. The current session is scheduled to end March 8.

In other action, the House gave prfeliminary approval today to a bill sponsored by Del. Mary A. Marshall (D-Arlington) that would require annual automobile emission tests to reduce air pollution in Northern Virginia.

The bill narrowly squeaked through committee last week after Environmental Protection Agency officials warned legislators that the Washington suburbs and the Richmond area faced a cutoff of more than $128 million in federal air and water pollution funds if the measure were not approved.

But before it passed the bill, the committee struck Richmond from the inspection requirement. That move prompted a telegram from EPA regional official Jack J. Schramm to Gov. Dalton, which was released today, warning that the bill in its present form was inadequate and that EPA had begun preliminary steps to freeze the federal funds for Virginia.