RICHMOND — Virginia could soon boast some of the cheapest gasoline prices in the country as next-door neighbor Maryland is on track to become one of the most expensive places to fill up, according to the America Automobile Association.

Both states will make changes to their gas taxes in the next two weeks. In Virginia, taxes will go down by about 6 cents per gallon as part of a transportation funding overhaul that also imposes $1.2 billion in new and higher taxes.

If the savings from the gas tax is passed on to consumers — something that is not guaranteed because the reduction is to a wholesale tax — commonwealth gas prices could be among the five lowest in the nation, AAA Mid-Atlantic said in an analysis issued Wednesday.

In Maryland, the gas taxes will go up by about 3.5 cents per gallon, and will rise by 21.1 cents per gallon by fiscal year 2018, AAA said.

“In the long term, Maryland could emerge as one of the most expensive places in the country to purchase gasoline,” AAA said. “This could be welcome news for some Virginia gas retailers as penny-wise customers drive across state lines for cheaper gas prices at filling stations in Virginia.”

Maryland’s General Assembly raised the gas tax this year under the Transportation Infrastructure Investment Act.

Starting July 1, Virginia will swap a 17.5 cents-per-gallon sales tax on gasoline for a 3.5 percent wholesale tax on motor fuels. The new, percentage-based tax translates to about 11.7 cents per gallon at current prices, AAA said. But the new tax will also keep pace with the rate of inflation — something the current flat, per-gallon tax, set in 1987, has not done — so the savings will diminish and eventually disappear if gas prices rise.

Virginia also imposed $1.2 billion in new and higher taxes as part of the $1.4 billion-year transportation package, which fund projects to improve the state’s clogged road, highway and rail systems. Sales tax on nonfood merchandise will rise from 5 percent to 5.3 percent under the new law.