Brazil's worst credit crunch in two decades is forcing the nation's debt-laden grain producers, sugar mills and coffee farmers to curb investment, making one of the world's top farm exporters miss out on a recovery in global commodity prices.

Banks, hit by a wave of defaults and bankruptcies triggered by the country's harshest recession in eight decades, tightened credit bringing lending growth to a 17-year low in April. Agricultural producers, which borrowed heavily in the past years to fund rapid expansion, were among those hit the hardest.

"We've not seen credit contract like this in recent history," said Alexandre Figliolino, who advises agricultural firms on structured credit and capital markets for consultancy firm MB Associados. "We may lose two years of farm expansion."

Several bankers told Reuters they expected credit to remain tight for at least another year, extending a sharp slowdown in farm production.

Area planted to grains, including soybeans and corn, grew only 0.3 percent this year, compared with growth of 3 percent in 2015 and 5 percent in 2014, a Reuters analysis of Agriculture Ministry data showed.

Soybean and corn production fell this year for the first time since 2011 and 2013, respectively. Although exports for both crops were up strongly over the past year due to the strong dollar, analysts expect corn exports to retreat until June 2017 due to local shortages facing livestock producers.

Coffee exports have also declined in recent months compared to record 2015 levels, as producers rebuild depleted stocks after two years of drought.

The squeeze coincides with a recovery in global commodity prices. Sugar prices are at the highest in nearly 3 years; soybeans are at a two-year high; and coffee and corn prices are near their highest in almost a year. Brazil is No. 2 corn exporter and the top exporter for the other three commodities.

All four commodities have recently suffered major losses due to bad weather or market conditions, depleting producers' capital or loading them with more debts, exacerbating the contraction in credit.

On Thursday, Marcos Lutz, chief executive of Brazil's largest sugar producer Cosan SA, said cane crushing would be smaller than expected in the current 2016 season. Despite the biggest global sugar deficit in decades, Lutz expected no investment in capacity in the short or medium term because of the funding constraints for many mills.

Macquarie Bank Ltd, Itaú Unibanco Holding SA and Rabobank NA are among banks refinancing or even renegotiating maturing credit to farmers before offering them new working capital and investment loans. Banco Pine SA, ABN Amro Group NV, Credit Agricole SA and others have followed suit.

Odebrecht Agroindustrial SA, privately-held grain producer Grupo Bom Jesus SA and farming company JPupin Ltda are among the large producers that are restructuring debt or entering creditor protection, after amassing more than 15 billion reais ($4.4 billion) in combined liabilities.

With the benchmark borrowing rate at 14.25 percent, near a decade high, and tougher lending terms, producers are relying more on barter, said a recent report by Imea, a research institute based in Mato Grosso, Brazil's biggest grain state. Multinationals are also more active in short-term crop financing.

With smaller lenders in retreat, state-controlled Banco do Brasil SA, the No. 1 farming lender, ramped up harvesting and crop lending at subsidized rates by 44 percent this year.

Still, industry leaders say credit from private-sector banks, which account for about 40 percent of Brazil's outstanding agriculture loans, remains essential.

That credit, though, has become much harder to get.

An executive at one of the Brazilian banks dealing with large- to mid-sized agricultural borrowers said clients who in the past would get a 20 million-real loan, would only get approval for half of that sum now.

"Some farmers will go broke in these conditions," said Marco Parzianello, who runs a large farm in Sorriso in Mato Grosso. "We held off on expansion to build up cash reserves and we are lucky we did."