This paper develops a multiperiod investment portfolio model that includes risky farmland, risky and risk-free nonfarm assets, and debt financing on farmland in the presence of transaction costs and credit constraints. The model is formulated as a stochastic continuous-state dynamic programming problem, and is solved numerically for Southwestern Minnesota, USA. Results show that optimal investment decisions are dynamic and take into account the future decisions due to uncertainty, partial irreversibility, and the option to wait. The optimal policy includes ranges of inaction, states where the optimal policy in the current year is to wait. The risk-averse farmer makes a lower investment in risky farmland reflecting risk-avoiding behavior. We find that, in addition to risk aversion, the length of the planning horizon affects risk-avoiding behavior in investment decisions. In contrast to a static model, changes in the riskiness of returns affect optimal investment decisions even when the decision maker is risk neutral. Finally, we find that higher debt financing on farmland is optimal when risky nonfarm assets can be included in the optimal investment portfolio and that the probability of exiting farming increases with the risky nonfarm investment.