Northern Virginia's often-feuding localities reached a tentative agreement last night on how to divide the region's new gasoline sales tax to help pay Metro's mounting operating deficits.

The chief beneficiaries of the tax, which will go into effect at 2 percent on July 1 and then rise to 4 percent two years later, are expected to be Arlington and Alexandria.

Up to now, Fairfax officials have complained that their county would raise more revenues than would be returned to pay the juridiction's share of Metro debts. But at last night's meeting of the Northern Virginia Transportation Commission, the county's four members joined in a unamimous vote that accepted an allocation formula favored by Arlington and Alexandria.

"I don't like it," said Fairfax Supervisor Joseph Alexander (D-Lee), the county's senior member on the commission, "but that's reality."

The regional gasoline sales tax, enacted by the Virginia General Assembly earlier this year, is expected to raise $11 million in the first full year of collection and $22 million the following year, when it goes to 4 percent. The center of the controversy between Fairfax and its Northern Virginia neighbors, Arlington and Alexandria, was how the money should be divided.

Fairfax wanted to get back all the money that was raised through gasoline sales in the county, which has a higher proportion of service stations than the closer-in suburbs. The county is assigned 46 percent of the fiscal 1981. Metro deficit, but county officials claimed that up to 60 percent of gasoline tax revenues would be raised in Fairfax.

Yesterday, state Attorney General J. Marshall Coleman said in an opinion that "the fuel tax revenues must be 'shared' on the same basis as costs are shared" -- the point on which Arlington and Alexandria had insisted.

The regional tax for Metro deficits is a response to the U.S. government's demand that the region come up with a "stable and reliable source" of revenue for deficits as a condition for more federal money to complete the planned 101-mile Metro rail system. The tax probably will never cover more than one-third of Metro's operating deficits, and the balance will have to be paid through other local taxes, as in the past.

Last night's tentative agreement must be ratified by local governing bodies before the transportation commission gives its final approval.