SIMPSON, Australia — James Guy had been a dairy farmer since he was 15, and at 55, he thought he’d be preparing for retirement. Instead, he struggled to make the payments on a bank loan after the price of milk fell and never recovered.

One night in November 2016, his wife, Mary, who was working part-time as a nurse to help make ends meet, came home to find he had hanged himself.

“When a farmer is looking down the barrel of having to sell his farm or lose his farm or give up the profession he’d done all his life, it’s devastating,” Ms. Guy said, her voice wavering, from her farmhouse in Simpson, a town in Australia’s dairy heartland of Victoria. “They just lose their identity.”

Family farms like Mr. Guy’s have been the producers of Australia’s agricultural bounty, and the bedrock of its self-image as a nation of proudly self-reliant types, carving a living from a vast continent. But as Australia’s rural economy has boomed on the back of growing exports, small farmers have not always shared in the bounty, with many forced into borrowing money or selling their farms.