Soil acidity is a major limiting factor for crop production in many farming systems worldwide. Lime application is the most common practice to mitigate soil acidity. There are complex economic interactions between application of lime and nitrogen fertilizer, with the greenhouse gas emissions associated with the use of these inputs adding further complexity. We employ a non-linear dynamic optimization model to determine economically optimal application strategies for lime and nitrogen fertilizer accounting for the social cost of the resulting emissions of greenhouse gases. The model is applied in three zones with different rainfall levels, in the northern wheatbelt of Western Australia. Rainfall has important influences on results through its effect on the dissolution and leaching of lime, leaching of nitrogen, and the yield potential of crops. Results show that nitrogen-related decisions, such as the type of nitrogen fertilizer and crop rotation, have a substantial impact on optimal lime application rates and resulting emissions. For example, the use of ammonium sulfate, rather than urea, reduces emissions. Similarly, by allowing a reduction in nitrogen fertilizer use the incorporation of legume crops like lupin can reduce emissions by 50%, relative to a wholly non-legume crop rotation. Although carbon pricing reduces emissions, the magnitude of the reductions is modest in all modeled scenarios. The private cost to farmers of a carbon tax in this case study region is small, although the net social benefit of the carbon tax in this case study is smaller still, even without accounting for the transaction costs of operating the tax system.