A mathematical model description of anaerobic digestion of animal residues was developed, taking into account material and energy balances, kinetics, and economics of the process. The model had the flexibility to be applicable to residues from any size or type of animal husbandry operation. A computer program was written for this model incorporating a procedure for process optimization, based on minimum unit gas cost, with the optimization variables being digester temperature, retention time, and influent volatile solids concentration. The computer program was used to determine the optimum baseline process conditions and economics for the fuel gas production via anaerobic digestion of residues from a 10,000 head environmental beef feedlot. This feedlot - at the conditions for minimum unit gas cost - was calculated to produce 8500 m3 (300 MCF)/day of methane at a cost of $4.90/GJ or $0.183/m' ($5.17/MCF [CH4]), with a total capital requirement of $1,165,000, a total capital investment of $694,000, and an annual average net operating cost of $370,000. No credit for possible refeed of digester effluent was included but a cost of $2.78/Mg ($2.50/ton) for the raw manure was incorporated. The major contributions to this unit gas cost were due to labor (37%), raw manure (11%), power for gas compression (10%), and digester cost (13%). A sensitivity analysis of the unit gas cost to changes in the major contributions to unit gas cost was performed, and the results of this analysis indicated areas in the anaerobic digestion system design where reasonable improvements may be expected so as to produce gas at a more economically feasible cost. This sensitivity analysis included the effects on unit gas cost of feedlot size and type, digester type, digester operating conditions, and economic input data. For example, a 40,000 head environmental feedlot was computed to produce methane for $1.42/GJ or $0.050/m3 ($1.50/MCF), using a continuously stirred tank reactor digester and taking a credit for the digester effluent as refeed.