Biofuel made from conventional (e.g., maize (Zea mays L.)) and cellulosic crops (e.g., switchgrass (Panicum virgatum L.) and Miscanthus (Miscanthus × giganteus)) provides alternative energy to fossil fuels and has been considered to mitigate greenhouse gas emissions. To estimate the large-scale carbon and nitrogen dynamics of these biofuel ecosystems, process-based models are needed. Here, we developed an agroecosystem model (AgTEM) based on the Terrestrial Ecosystem Model for these ecosystems. The model was incorporated with biogeochemical and ecophysiological processes including crop phenology, biomass allocation, nitrification, and denitrification, as well as agronomic management of irrigation and fertilization. It was used to estimate crop yield, biomass, net carbon exchange, and nitrous oxide emissions at an ecosystem level. The model was first parameterized for maize, switchgrass, and Miscanthus ecosystems and then validated with field observation data. We found that AgTEM well reproduces the annual net primary production and nitrous oxide fluxes of most sites, with over 85% of total variation explained by the model. Local sensitivity analysis indicated that the model sensitivity varies among different ecosystems. Net primary production of maize is sensitive to temperature, precipitation, cloudiness, fertilizer, and irrigation and less sensitive to atmospheric CO2 concentrations. In contrast, the net primary production of switchgrass and Miscanthus is most sensitive to temperature among all factors. Nitrous oxide fluxes are sensitive to management in maize ecosystems, and sensitive to climate factors in cellulosic ecosystems. The developed model should help advance our understanding of carbon and nitrogen dynamics of these biofuel ecosystems at both site and regional levels.