By Amrith Ramkumar

Americans are starting to capitalize on low prices at the gas pump as states loosen travel restrictions, a boon for the battered energy industry and a hopeful signal for the U.S. economic recovery.

With more states easing lockdown measures enacted to fight the spread of the coronavirus, people are gradually hitting the road and causing modest car traffic in cities from Miami to San Francisco. The slight increase in congestion comes with beaches and summer destinations opening and many people avoiding public transportation and airplanes.

That uptick in driving coincides with a nascent recovery in consumer spending, fueling hopes that the economy is rebounding from the worst of the virus-induced slowdown.

The optimism is driving a rally in investments from stocks to commodities. It powered the S&P 500 and oil prices last week to their highest level since early March. Meanwhile, with more people driving, the national average price for a gallon of regular gasoline climbed in four consecutive weeks through May 25 to $1.96 from a four-year low of $1.74 hit in late April, data from tracking firm GasBuddy show.

Prices are still well below where they started the year. But their rebound, and the bounceback in oil prices, represent an initial step for the energy sector's survival. Producers like Chevron Corp. and Occidental Petroleum Corp. are slashing supply with crude still below levels that make most projects profitable. Some investors expect those production cuts and a continued rise in travel to buoy energy prices moving forward.

Matt Jackson has been driving more in Philadelphia since returning to work a few weeks ago. The 39-year-old judicial aide and paralegal student has been working alternate days and lives about 10 miles from the court building where he works. He has noticed more traffic on highways lately and hopes to travel to New Jersey beaches this summer.

"Philadelphia is always a jumping place, and it's coming back," he said. "As things begin to reopen, I do see more people." Gas prices in the area have risen to about $2.20 a gallon from a recent low of $2.10. Mr. Jackson said the low prices add incentive to take longer drives.

The energy crash has battered refiners that turn crude into fuel products, with companies including Marathon Petroleum Corp., Valero Energy Corp. and Phillips 66 posting some of their worst earnings in years for the first quarter. Those companies typically do well when oil prices are low and people are taking advantage by driving more, but millions of people didn't drive for much of March and April due to lockdowns.

Demand for gas is slowly starting to creep back. Requests for driving directions on Apple Inc.'s Maps app are back around mid-January levels, while data from Dutch location technology firm TomTom International BV show traffic congestion gradually climbing in some large U.S. cities, though it is still down substantially from March levels in many.

"We're already seeing some improvement in demand, and this is going to continue as people return to more normal activities," Valero CEO Joe Gorder said on a call with investors and analysts in late April. Shares of Valero, Phillips 66 and Marathon Petroleum have each rebounded 46% or more so far this quarter.

Still, refining activity in the U.S. remains well below normal levels, and many analysts expect a bumpy recovery until more of the population feels comfortable traveling long distances. The speed of recent price moves has made the current environment even more challenging for energy companies. One price of U.S. crude dropped below $0 a barrel for the first time ever on April 20, meaning holders of the futures were paying to get rid of them due to a lack of available storage.

Oil prices have since rebounded to the mid-$30s a barrel but are still at levels that would leave much of the energy industry languishing. If prices keep rising, some investors expect producers to lift supply in response, another factor that could slow the recovery.

"The first leg of a recovery from a really low point is the easiest part, " said Rebecca Babin, senior energy trader at CIBC Private Wealth Management. "There's still a lot of crude around." She has been driving more recently and has noticed more cars on the road in Hoboken, N.J., but expects it to take time for demand to fully rebound.

The recent rise in fuel prices is also a reminder of the big disparities across states due to a combination of state and local taxes, refining costs and pricing by energy companies. Prices in California are at about $2.90 a gallon, while gas costs roughly $1.65 in Texas.

Bob Haines, a 59-year-old who runs a small auto repair shop in Waukegan, Ill., often travels a few miles north to Wisconsin to fill up because gas is much cheaper there. Prices are currently at about $1.85 a gallon nearby in Wisconsin, 40 cents cheaper than where he lives.

While Mr. Haines and his family are still limiting their driving, he is noticing more activity in the area, particularly in Wisconsin, where the state's top court overturned the state's coronavirus shutdown order last month.

"People are flocking to the bars, they're flocking to the restaurants," he said. "It appears we're getting into pre-Covid-19 traffic patterns again," he added, referring to the disease caused by the coronavirus.

Demand for ride-shares has risen recently in Fort Worth, Texas, as businesses in the area reopen, said Katrina Titze, a 34-year-old driver for Lyft Inc. and consultant.

Ms. Titze, who drives about 150 to 200 miles a day in her Toyota Highlander, said the price of a gallon of regular gasoline in the area has risen to about $1.60 from a recent low of $1.25.

She has driven throughout the pandemic -- transporting everyone from health-care workers to Amazon.com Inc. employees -- but recently noticed an increase in requests to travel to bars and restaurants.

"People are starting to be more social and go out," said Ms. Titze.

Write to Amrith Ramkumar at amrith.ramkumar@wsj.com