Many agricultural soils are naturally acidic, and agricultural production can acidify soil through processes such as nitrogen (N) fixation by legumes and application of N fertiliser. This means that decisions about mitigation of soil acidity (e.g. through application of lime), crop rotation and N fertiliser application are interdependent. This paper presents a dynamic model to determine jointly the optimal lime application strategies and N application rates in a rainfed cropping system in Western Australia. The model accounts for two crop rotations (with and without a legume break crop), for the acid tolerance of different crop types, and for differences in the acidifying effect of different N fertilisers. Results show that liming is a profitable strategy to treat acidic soils in the study region, but that there are interactions between N and acidity management. Choice of fertiliser affects optimal lime rates substantially, with the use of a more acidifying ammonium-based fertiliser leading to higher lime rates. The optimal liming strategy is also sensitive to inclusion of a legume crop in the rotation, because its fixed N can be less acidifying than fertiliser, and it allows a reduction in fertiliser rates. Higher rainfall zones have greater N leaching, which contributes to a higher optimal rate of lime. We find that injection of lime into the subsoil increases profit. Optimal lime rates in the absence of subsoil incorporation are higher than usual current practice, although the economic gains from increasing rates are small.