Russia's invasion of Ukraine last week has sparked turmoil in agricultural markets just as Minnesota farmers prepare for this spring's planting.

The farmers see opportunity but also economic danger — and a lot of uncertainty.

Prices for corn and soybeans have returned to the highs of last spring and summer, a level not seen in seven to eight years. Wheat prices have soared as worries rose about supply. Russia and Ukraine together account for nearly one-third of global wheat exports.

At the same time, farmers are being pinched by fuel prices not seen in several years — partly a result of the Ukraine crisis — coupled with dramatically escalating fertilizer prices. And the rising price of grain, a key component of animal feed, hurts Minnesota's livestock farmers.

"There are no free rides here," said Michael Swanson, Wells Fargo's chief agricultural economist.

Plus, any sustained grain price increases will put more pressure on already fast-rising food prices. In January, U.S. food prices climbed more than 6%, the largest year-over-year increase since 1982, the federal Consumer Price Index showed.

Russia's invasion of Ukraine could have longer-term consequences on agricultural markets.

"This is a very serious war," Swanson said. "This is not just a skirmish."

For ag markets, the duration of the conflict and how much economic upheaval comes with it are the big questions, said Bill Moore, Lakeville-based chief risk officer for Compeer Financial, a cooperatively owned agricultural lender.

So far, western nations haven't slapped sanctions on Russian grain exports, but that could change. If the fighting lasts only a short time, Ukrainian farmers could at least get their crops planted this spring.

But the longer the military conflict, the greater the risk.

"What Ukrainian farmer is going to go out and plow their field at the risk of getting hit by a missile?" Moore said.

Swanson said the window for planting this year's crop in Ukraine could be "greatly diminished. I would suspect losing a crop year in Ukraine is very high right now."

Ukraine is one of the world's largest exporters of wheat and corn. If Ukraine's corn crop is stunted by war, it will not only push up prices but leave a hole in the international market, one that might well be filled by U.S. farmers.

The United States is the world's largest corn grower. Only this country and Brazil have the acreage and export facilities to significantly make up for lost Ukrainian corn output, Swanson said.

And Minnesota is one of the nation's largest corn-producing states. Farmers in the state planted about 8.5 million acres of corn last year, with soybean acreage close behind, federal data show.

Still, the Ukraine effect on this year's corn market is highly uncertain, said Bryan Biegler, a corn and soybean farmer in Lake Wilson, Minn., and president of the Minnesota Corn Growers Association.

"We are kind of just sitting and waiting to see what will happen," he said.

Many Minnesota farmers plant both corn and soybeans, and 2021 was the best year for both in at least seven years. Corn topped $7.50 a bushel and stayed above $6 — considerably higher than prices since 2013 — before falling back some in late July.

Corn began rallying again in late December as demand remained high while dry weather began weighing on Brazil's corn crop. Corn briefly topped $7 a bushel last week and remains just below that mark.

Soybean prices also hit multiyear highs in 2021 for some of the same reasons as corn. They also jumped last week, topping $16 a bushel and hitting a nine-year high — even though neither Ukraine or Russia is a major soybean exporter,

Corn and soybean prices "kind of follow each other," Biegler said.

Wheat prices have generally shot up to levels not seen in nine years, though the futures price Friday for hard red spring — the variety grown in Minnesota — was about the same as it was in November.

Wheat is dwarfed by corn and soybeans in Minnesota, with about 1.2 million acres of hard red spring planted last year.

Corn and soybeans are simply more profitable than wheat. So when farmers have the choice, as they do in much of Minnesota outside the far northwestern counties, they opt for corn or soybeans.

And even higher wheat prices may not lead to significantly more wheat acreage this year in Minnesota.

"It might push some to plant a little more wheat, but right now, it's hard to tell," said Mike Gunderson, president of the Minnesota Association of Wheat Growers. He farms wheat, corn and soybeans and raises livestock near the northwestern Minnesota town of Bejou.

"It's not just wheat that is rallying, it's corn and soybeans, too," he said. So, wheat farmers who raise other crops have just as much of an incentive to plant them.

Plus, wheat is a more truly global crop than corn and soybeans, so there are several countries that could fill any gap created by the Ukraine war.

"It seems like everyone in the world can grow wheat," Gunderson said.

While crop prices are relatively high, farmers like Gunderson are wrestling with soaring input costs.

"Fuel is way higher than a year ago and fertilizer is astronomically higher," he said.

Those same high oil and natural gas prices that are denting consumers' motor fuel and heating budgets are eating away at farmers' pocketbooks, too — think tractors and other farm equipment.

Corn particularly sucks up fertilizer. And fertilizer costs are about $345 per acre right now, up from $143 in 2020, said Compeer's Moore. Most farmers put down fertilizer after last fall's harvest, or they bought the stuff in 2021 for spring applications.

But fertilizer costs were already high last fall, about $225 per acre, Moore said. Supply chain bottlenecks and general inflation have pushed up prices. So have climbing costs for natural gas, a big part of nitrogen fertilizer production.

The market could get uglier.

Russia is one of the largest fertilizer producers in the world. So far, western governments haven't sanctioned Russian fertilizer.

"Sanctions would absolutely affect fertilizer pricing for this fall," Moore said.