Excessive phosphorus accumulation in the soil poses a threat to water quality. Livestock agriculture is viewed as a primary contributor of nonpoint source phosphorus to rivers, lakes, and the Chesapeake Bay. Environmental policies are being implemented that influence the management decisions and profitability of Pennsylvania dairy farms. This research uses stochastic dynamic programming to determine the optimal management decisions for a spring-calving dairy farm using management-intensive grazing when disincentives exist for allowing excessive accumulation of phosphorus in the farm''s soils. Linear and multi-objective programming are used to create optimal feed rations for the herd being modeled. A simulation approach is developed to summarize the optimal decision rules. The results show that to reduce the soil phosphorus to an acceptable level in the steady-state regardless of the initial state of nature, the minimum cost, in terms of foregone profit, is $212 per acre per year. The optimal management strategy in the face of phosphorus loading is to rapidly reduce the herd size until soil phosphorus levels are under control.