Offshore wind projects are facing an economic crisis that erased billions of U.S. dollars in planned spending last week — just as the world needs clean energy more than ever.

A unit of Spain’s Iberdrola SA agreed to cancel a contract to sell power from a planned wind farm off the coast of Massachusetts. Danish developer Orsted A/S lost a bid to provide offshore wind power to Rhode Island, whose main utility said rising costs made the proposal too expensive. Swedish state-owned utility Vattenfall AB scuttled plans for a wind farm off the coast of Britain, citing inflation.

Soaring costs are derailing offshore wind projects even as demand for renewable energy soars. Extreme heat driven by climate change is straining electric grids all over the world, underscoring the need for more power generation — and adding urgency to calls for a faster transition away from fossil fuels. In Europe, the move to reduce reliance on Russian oil and gas has also given clean-energy projects momentum.