Dean Foods Co., the biggest U.S. milk company, filed for bankruptcy protection, a fresh setback to a U.S. dairy industry struggling against declining U.S. milk consumption and rising competition.

Dean and dairy farmers for years have grappled with consumers’ decadeslong move away from traditional cow’s milk, as beverage sales shift toward bottled water, fruit juices and milk alternatives made from soy and oats.

Within...