This paper develops a dynamic computable general equilibrium model in which optimizing agents evade taxes by operating in the underground economy. The cost to firms of evading taxes is that they find themselves subject to credit rationing from banks. Our model simulations show that in the absence of budgetary flexibility to adjust expenditures, raising tax rates too high drives firms into the underground economy, thereby reducing the tax base. Aggregate investment in the economy is lowered because of credit rationing. Taxes that are too low eliminate the underground economy, but result in unsustainable budget and trade deficits. Thus, the optimal rate of taxation, from a macroeconomic point of view, may lead to some underground activity.