A couple of months ago, the bulls ran the oil markets. Now the bears have taken over.

Always volatile, oil prices have tumbled more than 20 percent since late April because of growing fears that demand is weaker than expected as the global economy slows. Investors are also worried that President Trump’s trade war with China and his threat to put tariffs on imports from Mexico could depress growth even more. On Wednesday, crude oil futures in the United States closed at $51.68 a barrel, down 3.4 percent for the day, even as the stock market closed higher.

The outlook for oil prices was much different just six weeks ago, when the Trump administration was tightening sanctions on two leading producers, Iran and Venezuela, and civil war was breaking out around Libya’s capital. Some analysts speculated that there wouldn’t be enough oil to go around and that prices could jump to $90 a barrel or even higher.

“Everybody is surprised and now doubting projections of global demand growth,” said Tom Kloza, global head of energy analysis at the Oil Price Information Service. “It’s not as though there has been a rapprochement with Iran. It’s not as though there has been an increase in the rig count in the United States or Canada.”

The decline of crude oil prices is just one of the many signals that markets have sent in recent weeks darkening the outlook for the global economy. Prices for other industrial commodities such as copper, nickel and steel have declined. Stock markets in countries highly dependent on global trade, such as South Korea, Japan, Germany and Taiwan, have also fallen.