Pulling up to the gas station can be an exercise in sticker shock, especially if you live in California or New York. But it’s not just the price of crude oil that determines gasoline prices, and even if the U.S. produced all of the oil it consumed it still wouldn’t make much difference. In fact, relative to other developed countries, U.S. consumers get off lightly.

First a bit about what U.S. consumers pay: according to the U.S. Energy Information Administration (EIA), the average price of a gallon of regular gas in May 2014 was about $3.67. For the week of June 23, a gallon of regular gas would set you back $3.70. A French driver would have paid about $7.83, a British one $8.94. In Norway, which produces some 1.8 million barrels of oil per day, a gallon of gas hits the $9.90 mark.

A big part of that is gas taxes. The U.S. federal government levies an 18.4-cent tax on gasoline (24.4 cents on diesel). Absent taxes, a gallon of gasoline is pricier in the U.S. than in the U.K. ($3.18) and France ($3.37). There are also state and local taxes to consider; if you’re buying gas in New York State, you’ll be paying the highest taxes in America at 50.6 cents per gallon as of 2013, according to the Tax Foundation. Alaska, where much of America’s oil comes from, has the lowest at just 8 cents.

According to the EIA, in May 2014 the average cost of a gallon of gas was 65% based on the underlying crude oil, 13% refining, 12% taxes (federal, state and local), and 11% distribution and marketing. (For related reading, see: Why You Can't Influence Gas Prices.)

Proximity Helps…

One might think that being an oil-producing nation would cut the price down. It does, but that’s largely because of subsidies. The cheapest gasoline in the world is in Venezuela. Globalpetrolprices.com, which monitors such data, had it at 4 cents per liter, or about 15.12 cents per gallon. Saudi Arabian gas stations charge about 60 cents per gallon. OPEC countries generally come in under a dollar or near to it, but among the top 10 cheapest gasoline destinations is Syria (about 30 cents), which isn’t an OPEC member state, nor does it produce significant amount of oil. (For related reading, see: Commodity Investing: 101.)

…But Not as Much as You’d Think

Intuitively, one might expect the price of gas to be cheaper where there’s no cost to transporting the crude. But that isn’t always the case, because the oil has to be refined into gasoline. This is one reason that the average price of gas sans taxes in developed nations tends to be about the same. No matter where you are the gas is likely going to the same refineries as everyone else’s. In the U.S., some of the largest refineries are run by Exxon Mobil Corp. (XOM) and BP plc (BP), in Texas and Louisiana. They can handle about a half a million barrels per day. Others are owned by independent companies such as Marathon Oil Corp. (MRO), or even state-owned outfits such as Venezuela’s PDVSA. The largest refinery in the world is in India, the Jamnagar Refinery operated by Reliance Industries, at 1.2 million barrels daily. (For related reading, see: The Price of Gasoline is All About Location.)

Saudi Arabia has refineries, but the country’s entire capacity is about 2.1 million barrels per day. The country consumed 3 million barrels of crude per day, and a lot of that was for gasoline and fuel oil. The country has plans to expand capacity, but it will take some time for it to come on line.

When Disaster Strikes

A for the United States, the effect of refining capacity on price is visible when one looks at the price of gasoline in 2005. That was the year Hurricane Katrina hit much of the refining capacity along the Gulf Coast. The average monthly price of gas started the year at $2.27, and finished at $2.76, but within that general upward trend there was a spike to $3.47 for the month of September, almost entirely due to fears about the gasoline supply.

Oil prices went up as well, but the price trend for the year as a whole was actually steeper – some 42% for crude as opposed to 21% for gasoline. The spike in crude oil prices was a full 52% above the January 2005 figure—$71.01 per barrel against $46.53. For gasoline it was similar, but comparing the prices of the two commodities against their post-spike levels shows that oil came down less than 10% to $66.52. The peak gasoline price was 20% over the year-end figure.

All this means that the hit to gasoline consumers—driven largely by the fears over refining capacity—probably meant sharper variations in the price at the pump.

Similar upward pressure on prices can also occur due to geopolitical events, especially when they occur in or near oil-producing nations. Risk of an oil-supply interruption can make gas prices spike.

A Global Market

The U.S. produces about 12% of the world’s oil, according to EIA figures, about 2.7 billion barrels per day. That’s on a par with some major producers such as Saudi Arabia. So why isn’t gasoline cheaper? Because oil isn’t bought and sold in individual countries; it goes into a global market.

So even though the U.S. produces a sizeable piece of the world’s oil, it also consumes a lot of it, too. And it’s not possible to mount a “buy American” campaign. There are nations that the U.S. declines to buy oil from, such as Iran, but that doesn’t affect the world price.

In fact, even if the U.S. produced as much oil as it could consume, the price of oil would only go down enough to reflect that production. Which means that “energy independence” might mean weaning ourselves from imported oil, but it won’t change the price of gasoline. (For related reading, see: Pump Profits with this Gasoline ETF.)

Type of Crude Is Irrelevant

The price of oil per barrel is also relatively independent of the kind of oil that it is, or how expensive it is to pull out of the ground. Tar sands and drilling in Alaska, which is pricier, might make a difference to the oil companies involved, but it would make no difference to the energy and petrochemical industries. No matter the source, out of every gallon of crude, about 51.4% is refined into gasoline.

Oil refineries also have to make money, but they have some leeway in how they price the end products. The “crack spread” is the margin between the price of the finished gasoline and fuel oil and the crude. Most oil refining companies, especially independents such as Valero Energy Corp. (VLO), for instance, have a certain margin already built in to account for price fluctuations. So the price increases they can impose will sometimes lag those of the price of crude oil.

On top of that the technology for refineries has moved forward to handle bigger loads more efficiently. The EIA notes that refinery yield has stayed relatively constant for the past twenty years. Absent a major shock to the industry it’s not likely to alter very much. All this means that gas prices will mostly track oil prices, with some kinks as refining capacity changes.

The Bottom Line

Many things factor into the price of gasoline. The biggest cost, at 65% of the price of the end product, is the underlying crude oil, often coming from volatile or inhospitable places. Transportation and refining and factor in about 13%, as well as taxes, which add almost as much to the cost. Finally, getting it to a location near you adds another layer of cost (11%). When considering the logistics and risks involved, it’s a wonder it isn’t more expensive.

Want to learn how to invest?

Get a free 10 week email series that will teach you how to start investing.

Delivered twice a week, straight to your inbox.