For decades, if you cared about the pennies in your pocket and you were able, you’ve opted to buy your gasoline outside of the District, where prices were 20 to 30 cents cheaper per gallon.

But the balance may tip in the opposite direction after lawmakers in Annapolis and Richmond recently tinkered with their gas-tax formulas to raise cash to meet transportation needs.

Gas prices are sure to go up in Maryland. It’s too soon to say for certain what a complex package of tax changes will mean at Virginia gas pumps. The governor’s office says prices will go down by 6 cents per gallon because the old 17.5 cent-per-gallon tax has been eliminated, replaced by a 3.5 percent state tax on the wholesalers who distribute gas.

Hardly anyone in Virginia claims to know for sure how that wholesale tax is going to play out at the gas pump, and not everyone is so optimistic as the governor.

“Gas prices are going up,” said AAA Mid-Atlantic spokesman John B. Townsend II, “but it’s going to be felt more in Maryland than it is in Virginia. D.C. will be very competitive for the first time in two or three decades when it comes to the price of gas.”

As Virginia lawmakers debated the changes two months ago, some claimed that they would cost drivers about $15 more a month.

Others aren’t so sure. Robert Chase of the Northern Virginia Transportation Alliance said that filling up at the pump “should be less, but how much less, I don’t think anybody can say for certain.”

It’s a bit less confusing in Maryland.

There, gas prices will begin to go up. They are going to increase in phases, with a 1 percent state sales tax tacked on as of July 1. That tax will increase to 2 percent in January 2015 and rise again to 3 percent in July 2015.

That sales tax will be in addition to the current state gas tax of 23.5 cents per gallon, which hasn’t changed since 1992. Another largely unnoticed but significant change is that the gas tax now will be hitched to inflation rather than be a flat tax that remains the same from year to year. Now it will jump with the Consumer Price Index, up to a maximum of 8 percent a year.

If you drive 15,000 miles a year in a car that gets 22 miles to the gallon, you’ll will pay an extra $27 per year after the July 1 increase hits, said Daraius Irani, executive director of the Regional Economic Studies Institute at Towson University. That number could reach about $136 a year by July 2016.

The magnitude of the changes is “not that big” because it will be felt in very small increments, Irani said. Still, drivers are often willing to go a little farther for cheaper gas.

“Drivers seek out the lowest-cost gas they can possibly seek out,” Irani said. “People find something cheaper, they’ll go out of their way to get it.”

Alberto Dominguez is one of those drivers. He lives and works in the District, but he recently tried to buy his gas in Maryland.

“If I know I’m going to Maryland, I hold off,” said Dominguez, 36, of Anacostia. “I know the gas there is cheaper.”

But he won’t go very far just to save a few cents on a gallon of gas.

“When you look at the overall math, how far would you be willing to drive to save a dollar?” Dominguez said.

Wendy Alcantara of Fort Washington drives more than 50 miles each day commuting to and from her nursing job at Sibley Memorial Hospital in Northwest Washington.

She said she typically fills up near home because it can be 40 cents less per gallon than at a station near the hospital. Alcantara would fill up in the District if it becomes cheaper, but at some point a flexibility on where you fill up can go only so far.

“If I need to get it, what can I do?” said Alcantara, 34. “It’s something that I need to get around, so I just have to keep budgeting for it.”

Changes in gas tax law in the states that surround the District may not be the last of it. The federal gas tax of 18.4 cents hasn’t been raised since 1993, and with the current transportation bill to expire next year, Congress already is exploring its money-raising options. While they’re looking for innovative approaches, bumping up the gas tax is the easiest option to meet expected revenue shortfalls.

For most people, higher gas taxes are coming.

“A gas tax is fair because it’s a user tax, because if the roads need to be fixed, it’s more fair to get that money from the people who use them,” said Andrea Weckstein of Great Falls.