Growth trends of animal farming pose a threat to water quality around the world. To find cost-efficient means to reduce nutrient loads from agriculture, detailed information on the abatement measures need to be incorporated in bioeconomic models. This study presents a theoretical framework that covers both animal and crop operations on farms. It describes the farmer decision making problem and incorporates nonlinear functions to capture the economic and biological aspects of the problem. The model is applied to Finnish dairy farms. The abatement cost functions are derived for nitrogen and phosphorus. Results indicate that abatement measures on fields should precede dietary changes.