Ouch. (Damien Dovarganes/AP)

Gasoline at the pump in California is typically about 40 to 50 cents more expensive than it is anywhere else in the country. The state's gas taxes are significantly higher than the national average and many of its retailers have to sell a higher-quality blend of gasoline in order to reduce smog and other pollutants. That all raises prices.

But over the past week, things have really gotten out of whack. California's gas prices have leaped an additional 50 cents to near-record highs, causing mass grumbling, a political headache for Governor Jerry Brown — and even inspiring car thieves to start siphoning off gas from cars and trucks in rental lots. Here's the chart o' doom:

So what happened? Why the chaos? As James Hamilton details over at Econbrowser, a handful of disruptions at key California refineries and a pipeline shutdown happened:

The Chevron refinery in Richmond (across the bay from San Francisco) has a normal capacity of 243,000 barrels per day, or 8.5% of the total petroleum products supplied to Petroleum Administration for Defense District 5, of which California is a part. But a fire at the Richmond refinery in August has significantly reduced its production.

The Kettleman-Los Medanos pipeline, which carries 85,000 barrels per day of crude oil to the San Francisco Bay Area, has been closed since mid-September due to organic chloride contamination. And on Monday, a power outage shut down ExxonMobil's 149,000-barrel-per-day Torrance refinery in L.A.

Two factors allow the price in California to spike much higher than the rest of the country. First, a different blend is required to meet California air quality standards. Second, there is little pipeline capacity to bring in refined product from elsewhere.

Severin Borenstein, an energy expert at UC Berkeley, adds that it's also possible some state refiners are taking advantage of the shortfall by withholding some of their gasoline in order to jolt prices even higher. The supply of special reformulated gasoline that California uses is produced by just a handful of companies, with Chevron alone controlling more than 20 percent of the market. In certain circumstances, price-gouging might be quite profitable. "It’s not a crazy notion," Borenstein notes, "it’s just extremely difficult to prove and, even then, not a violation of any law."

So is there anything California can do? One option, as Hamilton notes, is simply to wait out the crunch and try to adapt — these sorts of disruptions, while causing a fair bit of havoc, tend to be fleeting. Another possibility is that California could suspend some of its laws on air pollution. For instance, California's retailers are supposed to keep selling pricier summer-blend gasoline until Oct. 31. Winter-blend gasoline is cheaper and more readily available, but it also emits more polluting vapors. Brown has asked the California Air Resources Board to move up the date of the changeover to winter blends and allow more out-of-state gas imports.

Borenstein, however, offers up a more subtle policy idea. He notes that California's stricter standards for gasoline have been quite successful at reducing ozone pollution in a state that has historically had a horrific smog problem. The health benefits appear to have been substantial (pdf). So repealing the pollution rules altogether isn't necessarily a wise idea.

Instead, he proposes, California could slap a 25-cent tax on the lower-quality gasoline that other states use. In normal times, it wouldn't be worth it for California's retailers to sell the stuff — that's more than the additional production cost of the state's reformulated gasoline. But during a shortage, retailers could temporarily switch over to the cheaper, more-polluting gasoline, limiting the severity of the price spike. If the disruption is brief, this policy wouldn't have a big effect on air pollution — and California could use the extra revenue to take other measures to offset the increased pollution.

In any case, this is another reminder that the gasoline market can often behave quite unexpectedly at times. Broadly speaking, gas prices across the United States tend to rise and drop in tandem with oil prices. But when you toss in the quirks of refineries, state-level policies, and the placement of pipelines, prices can vary quite dramatically from state to state.

Related: Why gas prices vary so much from one state to the next