A dynamic stochastic general equilibrium model is used to study the optimal fiscal response to commodity price shocks in a small open low-income country. The model accounts for imperfect access to world capital markets and a variety of externalities associated with public infrastructure, including utility benefits, a direct complementarity effect with private investment, and reduced distribution costs. However, public capital is also subject to congestion and absorption constraints, with the latter affecting the efficiency of infrastructure investment. The model is parameterized and used to examine the transmission process of a temporary resource price shock under a benchmark case (cash transfers) and alternative fiscal rules, involving either higher public spending or accumulation in a sovereign fund. The optimal allocation rule between spending today and asset accumulation is determined so as to minimize a social loss function defined in terms of the volatility, relative to the benchmark case, of private consumption and either the nonresource primary fiscal balance or a more general index of macroeconomic stability, which accounts for the volatility of the real exchange rate. Sensitivity analysis is conducted with respect to various structural parameters and model specification.