The Maryland and Virginia legislatures moved closer to increasing gasoline taxes for motorists in their states yesterday, despite objections from suburban Washington lawmakers who have argued that too much of the money will go to rural highways and not enough to mass transit.

In Maryland, a key Senate committee approved a compromise measure that would raise the gas tax by 4.5 cents per gallon over the next two years and mandate that the money be used only for road and bridge maintenance and construction.

In Virginia, the House defeated a plan that would have earmarked one cent out of a proposed four-cent increase to Metro, making it more likely than ever that the General Assembly will pass a bill bitterly opposed by Northern Virginia politicians--one that would raise gas taxes by as much as 7 cents a gallon without giving any of that money to the regional subway system.

"You're looking at a potential seven-cent gas tax increase in Northern Virginia . . . , " said Del Warren Stambaugh (D-Arlington), after he and his colleagues from the Washington suburbs lost another hard round of lobbying yesterday. "That would probably create a desert in terms of gas stations. They wouldn't be able to compete at that level. It wouldn't become unreasonable for the motorist to drive over to the District or Maryland to go and buy gas."

In Maryland, the increase would occur over two years. The first-year increase would be two cents a gallon, the second year 2.5 cents. After that the tax would increase automatically a penny a year starting in mid-1984, as long as the wholesale price of a gallon of gasoline exceeds $1.35. The state now has a 9-cents-per gallon gasoline tax that has not increased since 1972.

Like their Virginia counterparts, several urban and inner suburban Maryland legislators were miffed by the latest gasoline tax proposals.

"I think that's a hell of a step," said Sen. Tommie Broadwater (D-Prince George's).

"We're socking it to the little guy," said Sen. Julian L. Lapides (D-Baltimore).

"Poor folks will get it," said Sen. Clarence W. Blount (D-Baltimore).

The proposal passed the Senate Budget and Tax Committee by a 9-to-4 vote, but the back-and-forth sniping during the panel's debate underscored the deep urban-versus-rural animosities that are likely to surface as the tax plan weaves its way through the legislature.

"It's not for Metro and it's not for mass transit in the cities," Broadwater complained. "It's for roads and bridges in rural areas."

One rural senator, Sen. Edward Mason (R-Washington County), protested that mass transit costs were the largest share of the state's transportation budget. "I'd be glad to put a toll road on I-270," which leads to Washington County, Lapides shot back.

The Senate committee's proposal would give the cash-strapped Department of Transportation considerably less money than Gov. Harry Hughes originally proposed under his own gasoline tax plan. Hughes had said last week that he would compromise and take the two cents this year, but that the state needed at least a three-cent increase next year to repair Maryland's deteriorating roads and bridges.

But the legislators rebuffed Hughes and limited the second-year tax increase to 2 1/2 cents, essentially telling the governor to take it or leave it.

"I'm not particularly pleased about it," said Transportation Secretary Lowell K. Bridwell. "But if the Senate and the House can agree on this, I'd rather see that than risk the defeat of the tax in an election year."

Sen. Laurence Levitan (D-Montgomery), chairman of the Senate budget panel, said he will move the package to the floor of the Senate by midweek and he predicted it will pass. "It was a very encouraging vote out of the committee," Levitan said. "If we got nine votes here, I think it will pass the Senate."

The House had agreed to wait until the Senate acted before moving the gasoline tax package. House Speaker Benjamin L. Cardin predicted last week that the gasoline tax would pass the House.

Virginia Gov. Charles Robb has said a gas tax increase is essential this year to cover a projected $360 million two-year deficit in state highway construction programs. State legislators, however, are locked in a bitter struggle over what form the increase in the existing 11-cents-per-gallon tax should take.

The Senate last month passed a $263 million package of highway user taxes, sponsored by state Sen. Edward E. Willey (D-Richmond) that includes a new 3 percent tax on wholesale gasoline sales. This would add four cents to the price motorists pay at the pump, but provide no new funding for Metro.

In the Washington suburbs, the measure's impact could be more pronounced. Area motorists are also facing, effective July 1, another scheduled 2 percent increase in the area's existing "Metro gasoline tax" passed by the General Assembly two years ago to provide funding for the transit system.

Passage of the Willey bill prompted Northern Virginia delegates to mount an intense campaign on behalf of a proposal they considered more equitable. Yesterday they were dealt a major setback when their proposal--a four-cent-per-gallon statewide gas tax increase that would have substituted for the Northern Virginia Metro gas tax rise--was narrowly rejected on the House floor by a 47-to-50 vote.

After that, Northern Virginia delegates held firm to their earlier threat to block any gas tax increase unless it includes Metro funding. Voting as a block they helped the House defeat a three-cent-per-gallon tax increase without statewide Metro money by a crushing 26-to-67 vote. With the vote on final passage of the bill delayed until today, however, Northern Virginians insisted that the ballgame was not yet over. "We've got another 24 hours to see if we can reason with some of these people who to date have been unreasonable," said Del. Gladys Keating, (D-Fairfax). "We have a slight lease on life."