The oil market is undergoing a stunning reversal as crude futures wipe out this year's gains after hitting their highest levels since 2014 just six weeks ago. The slump reflects a fundamental change in the outlook for the oil prices. A month ago, traders were concerned that a looming shortage of oil would push crude futures to $100 a barrel. Now, supply is expected to swamp demand at the start of 2019. As a result, oil prices have plunged more than $20 a barrel since the start of October, when Brent crude rose to nearly $87 a barrel and U.S. crude traded just shy of $77. Both benchmarks are now trading firmly in bear market territory, having fallen more than 20 percent from their 52-week highs. Along the way, U.S. crude has posted its longest losing streak since it began trading in New York more than three decades ago. The contract has now fallen for 12 consecutive sessions. It settled at $55.69 on Tuesday, its lowest closing price since Nov. 16, 2017. The roots of the pullback can be traced back to the most recent rally itself. At the peak of the run-up, many energy analysts said oil prices never should have risen so far so fast. Crude futures rose to four-year highs on Oct. 3 as the market braced for renewed U.S. sanctions on Iran, OPEC's third biggest producer. Through September, the threat of sanctions wiped about 800,000 barrels a day off the market, fueling speculation that some oil importers would struggle to find supplies.

Stock market sell-off

That left oil prices vulnerable to a pullback just as the stock market was about to sell off. One week after crude futures struck their highs, two-thirds of the stocks in the plunged into correction territory. That kicked off a broad market rout that saw investors shed risk assets, including crude futures. Oil and stocks do not always move in tandem, but the assets were closely correlated during last month's sell-off. Right around the same time that investors started dumping stocks and commodities, concerns about faltering oil demand sharpened.

Weaker consumption outlook

In October, both OPEC and the International Energy Agency said oil consumption would grow less than previously forecast, pointing to signs of slowing global economic growth due to trade tensions, rising interest rates and weak emerging market currencies. Forecasters grew particularly concerned about oil demand deteriorating in places like India, Turkey and Indonesia as oil prices hit new highs in October. "For many developing countries, higher international prices coincide with currencies depreciating against the U.S. dollar, so the threat of economic damage is more acute," the International Energy Agency said last month. The U.S. dollar has risen nearly 3 percent against a basket of currencies over the last two months. That makes crude oil, which is sold in dollars, more expensive to holders of other currencies.

Rising output

Meanwhile, the world's top three oil producers are pumping at or near all-time highs and the 15-member OPEC cartel is in the middle of a coordinated production increase. U.S. output has topped 11 million barrels per day in recent months, while Russia is pumping at post-Soviet era highs at roughly the same level. Saudi Arabia has trailed just behind at 10.6 million bpd in October. OPEC, along with Russia and several other producers, began capping their output in January 2017 to drain a global crude glut and end a punishing oil price downturn. However, they agreed to reverse course and hike output in June after cutting output more than they intended. The rising production and weakening demand outlook now has much of the market convinced that supply will outstrip the world's appetite for oil early next year.

Iran waivers

The Trump administration's decision to allow eight countries to continue importing Iranian crude for the next six months has also relieved upward pressure on oil prices. "That really messed up the calculus" for OPEC and its oil market allies, said John Kilduff, founding partner at energy hedge fund Again Capital. The group was pumping more oil to offset the anticipated drop in Iranian exports, but "the waivers really undercut that," Kilduff said. "They worked so hard over the last few years to balance the market. They sort of tripped into an oversupply situation," he told CNBC.