This article develops a model in which optimal capital structure and debt maturity are jointly determined in a stochastic interest rate environment. The model yields leverage ratios that are consistent in spirit with empirical observations. The optimal maturity and credit spread of an optimally issued debt are found to be smaller than observed values. The long-run mean of the interest rate is found to be a key variable in determining optimal capital structure and debt maturity. Furthermore, the interest rate volatility and the correlation between the interest rate and the firm's asset value play important roles in determining debt maturity.