The highest retail gasoline prices in years are the latest development to raise concerns about one of the longest-running U.S. economic expansions on record.

Drivers across the U.S. in May paid as much as $2.96 a gallon on average, the most since 2014. Prices have climbed to $3.63 in California and $3.39 in Washington, states where prices tend to be higher because of factors such as higher taxes, environmental regulations and a lack of pipelines that transport oil west. As of Monday, the national average was $2.86 a gallon....