BASF SE, one of the world’s largest chemicals companies, said it would reduce production of fertilizer ingredient ammonia, as it seeks to curb its natural gas use after Russia throttled flows to Europe.

Moscow began Wednesday reducing supplies via the Nord Stream pipeline, the largest Russian gas link to Europe, to around 20% of capacity. The reductions complicate the continent’s efforts to store enough gas ahead of winter, raising the specter for industry of costly rationing. European Union members this week agreed to sweeping cuts to natural-gas consumption, calling for countries to voluntarily reduce their gas use by 15% from August.

European gas prices surged to near record highs Wednesday, closing in on the March peaks that followed Russia’s invasion of Ukraine.

For BASF, the supply cuts and higher prices carry a heavy burden, as it uses the fuel both to generate power and as feedstock for products. The German multinational said Wednesday it would reduce it production of ammonia, for which natural gas is required, in a bid to reduce its demand.

Gas can account for up to 85% of the production cost of ammonia, according to the U.S. Department of Agriculture. Ammonia, in turn, is a key ingredient for many types of fertilizer.

While BASF said that the ammonia output cuts won’t affect farmers this year, as they have bought enough fertilizer and the harvest is already taking place, issues might arise next year.

“Ammonia is in a difficult situation,” BASF Chief Executive Martin Brudermüller said. “Next year’s availability of fertilizer might be worse. Fertilizer prices are skyrocketing.”

He said that this could mean lower harvests next year. “And if there are weather issues on top of this, that means there could be a shortage of important crops,” Mr. Brudermüller said, adding that this would be especially challenging for poorer countries at the end of the food-supply chain.

The company, which is responsible for as much as 4% of German gas demand, said it was buying extra ammonia from external suppliers to help mitigate the risks.

BASF said that dwindling Russian gas supplies were a threat to its manufacturing hub in Ludwigshafen, Germany, which is the world’s largest integrated chemicals complex. If gas supply falls significantly below 50% of Ludwigshafen’s maximum demand over a sustained period, it would have to stop production, the company said.

Meantime, Mr. Brudermüller said BASF expects to continue to operate the site at a reduced load, even in the case of gas-rationing measures by the German government.

BASF is also preparing to substitute fuel oil for gas as much as possible. It said that power and steam production in Ludwigshafen can partially be switched to fuel oil, which would substitute around 15% of the gas demand.

Gas-saving measures in the chemical industry are limited by current technology. Switching to renewables in the power supply and using biofuel feedstocks, including biomethane, won’t be able to substitute fossil fuels at large scale soon, analysts say.

Germany’s VCI chemical industry association has said that the chemicals sector, the country’s largest industrial gas consumer, requires around 135 terawatt hours of gas a year. The industry can save only two to three terawatt hours by using alternative fuels.

BASF said that if Russia cuts gas supplies to Europe further, it would seek to compensate for its loss of European production by ramping up sites outside of the continent. BASF has large sites in Louisiana and Texas, as well as in China.

In the second quarter, BASF’s gas bill rose by 800 million euros, equivalent to around $810 million, compared with a year earlier. The company has raised its prices and said it would continue to do so to offset this cost.

BASF raised its full-year guidance on the back of strong first-half results, but warned that it expected the global economy to cool amid the war in Ukraine and its impact on energy and raw-material prices.

“For the second half of the year, BASF anticipates a gradual cooling of economic development globally, but much more pronounced in Europe,” Mr. Brudermüller said.

Write to Georgi Kantchev at georgi.kantchev@wsj.com