AL KHARJ, Saudi Arabia — This is what it takes to run a mega-dairy in the scorching desert here: 180,000 Holstein cows, precisely cooled cowsheds, water pumped from deep underground, feed from Argentina and a state-of-the-art refrigeration system. To transport chilled milk and other products all over the Arabian Peninsula, add 9,000 vehicles.

None other than the Saudi king’s favored son, Deputy Crown Prince Mohammed bin Salman, has held up the dairy, Almarai, as a model for a country trying to wean itself from oil dependence. But even companies like Almarai, with no apparent connection to petroleum, rely on the cheap energy provided by the kingdom.

That is coming to an end. Low oil prices and an increasingly costly war in Yemen have torn a yawning hole in the Saudi budget and created a crisis that has led to cuts in public spending, reductions in take-home pay and benefits for government workers and a host of new fees and fines. Huge subsidies for fuel, water and electricity that encourage overconsumption are being curtailed. For Almarai, one of the top brands in the Middle East, that will mean $133 million from the bottom line this year, company officials said.