By Amrith Ramkumar

Gasoline demand in the U.S. has flatlined for much of the third quarter, keeping crude-oil prices near $40 a barrel and challenging the global energy industry heading into the final months of the year.

Fragile fuel demand joins other indicators of economic activity -- from consumer spending to hiring -- in signaling that growth is softening after a surge from April to June. That trend has many investors skittish as fall begins, particularly with November's presidential election quickly approaching and the federal government failing to pass additional economic-stimulus measures.

U.S. crude-oil prices are set to end the third quarter just below $40 a barrel -- almost exactly where they started it. Oil inched higher for much of the quarter before peaking above $43 on Aug. 26, then swung around the $40 level. Prices started the year above $60 and briefly dipped below $0 for the first time in late April, when pandemic shutdowns spawned a glut.

Some analysts are wary that surpluses could begin building again. Gasoline supplied by energy companies in the U.S., a proxy for demand, has stayed relatively flat over the past three months after surging from late April to late June, government data show. Fuel demand typically peaks in the summer and analysts are concerned that consumption could trail consensus forecasts as the weather cools in much of the country and people stay inside more.

Gasoline demand also is faltering in other key oil-consuming countries that have been hit hard by the coronavirus, such as India. And with many flights canceled, consumption of jet fuel around the world remains low.

In addition to hurting energy producers -- many of which are slowly increasing production after slashing output earlier in the year -- oil's lackluster quarter highlights the winding path for the economy in the months ahead. Perhaps no major financial asset has been hit harder by the pandemic than oil, and recent price moves signal that the recovery from coronavirus could take much longer than initially anticipated.

"It's hard to paint the bullish demand story for energy in the short term...I just don't see it," said Jennifer Rowland, senior energy analyst for Edward Jones. "Instead, I see all the warning signs."

U.S. crude futures recently traded at $39.98 a barrel. Brent crude futures, the global benchmark of prices, are at $42.35 a barrel and also have wobbled lately.

Analysts say prices are still too low for many producers to profitably extract oil, forecasting more bankruptcies and mergers and acquisitions in the months ahead. The S&P 500 energy sector, a group that includes producers such as Exxon Mobil Corp. and Chevron Corp. has fallen nearly 20% in the third quarter, though it remains well above a low point hit early in the year. The S&P 500, meanwhile, is up 8.1% for the quarter, despite a recent pullback.

"It doesn't look like there's going to be the type of growth in demand that producers really need to sustain a major price recovery at this point," said Andy Lebow, senior partner at Commodity Research Group. "It's clearly going to take time."

Hedge funds and other speculative investors remain cautious and have steadily lowered net bets on higher U.S. crude prices since mid-June, though net bullish bets have ticked up again recently, Commodity Futures Trading Commission data show.

Traders also are grappling with the prospect of higher oil output from Libya, a member of the Organization of the Petroleum Exporting Countries. Libya's National Oil Corp. has restarted production in recent weeks after two rival governments declared a cease-fire in the country's civil war last month, raising the prospect that Libyan exports could add to OPEC supply flowing through global markets.

The higher output could increase pressure on OPEC members and allies such as Russia to adjust to the Libyan output and comply with the group's production limits in an attempt to support crude prices.

A market-share battle between Saudi Arabia, the de facto head of OPEC, and Russia earlier in the year contributed to a collapse in crude prices even as global shutdowns dented demand. That was the latest example in recent years of OPEC surprising investors, and analysts are bracing for the prospect that supply could exceed demand if fuel consumption falters even more in the months ahead and Libyan output keeps rising.

"Someone has got to make room for that [oil]," Ms. Rowland said. "That just puts more reliance on OPEC, which is a tenuous place for the oil market to be."