(KTLA) – As gas prices continue to remain high around the country, savvy consumers often search for the best deal to get the most out of their hard-earned cash. Sometimes, finding the best price can come just by crossing a lane or two of traffic.

So why do gas prices vary so much from station to station?

Experts say it comes down to a few key factors: taxes, wholesale prices and profit margins.

So let’s start with taxes. According to NACS, the Association for Convenience and Fuel Retailing, all gas retailers must charge the federal gas excise tax, which is currently around $0.18. States also have their fees and taxes. In California, the tax is as high as $0.86. Alaska has the lowest state taxes on gasoline at about $0.33, according to NACS and the American Petroleum Institute.

But gas taxes can also vary from city to city. Gas stations could be just a street away from each other, but across city lines, and those cities could have different taxes on gas.

But the main reason for the disparity, experts say, comes down to margins and competition.

Gasoline retailers have to buy their gas from somewhere, and wholesalers have their prices. For gas stations, a large factor in how they determine prices comes down to the brand of gasoline they sell. Chevron is priced differently than Exxon, which is priced differently than Shell. Some are more expensive than others, and the customer pays for the added cost because gas stations don’t make huge profits on each gallon sold. Many consumers are OK with paying more for certain brands due to reputation or manufacturer recommendations.

And the higher volume of gasoline sold means the gas station probably gets a better wholesale price, which makes it easier for them to sell gas at a lower retail price.

Another thing to consider: Does the gas station have a convenience store on-site? Most gas stations make small profits from gasoline sales, but those with convenience stores make more than half of their total earnings off of the items sold inside, NCAS says.

Gas stations with stores tend to price their gas lower, knowing they’ll make up the difference in convenience store sales. The lower prices entice people to spend money in the stores where margins are much more profit-friendly for the business owner. So if you buy a large soda and some sunflower seeds, you’re likely helping to keep those prices down.

As in most industries, the biggest reason for the pricing disparity probably comes down to competition.

If a gas station without a convenience store is near one that has one, it might be beneficial to adjust those prices accordingly. If a gas station isn’t a name-brand business, it’ll have its own set of challenges that are different from the name-brand business, including fewer discounts on wholesale gasoline. A store that is inconvenient to drive to might have to lower its prices to entice customers who would typically go to the competitor across the street, which isn’t as much of a pain to get to.

There are numerous reasons why one gas station might sell gas for cheaper than its neighbor. Ultimately, it comes down to a complicated equation for business owners who want to maximize their profits while testing what the consumer will tolerate and prioritize.