a b s t r a c tIn sugarcane biorefineries, the lignocellulosic portion of the sugarcane biomass (i.e. bagasse and cane trash) can be used as fuel for electricity production and/or feedstock for second generation (2G) ethanol. This study presents a techno-economic analysis of upgraded sugarcane biorefineries in Brazil, aiming at utilizing surplus bagasse and cane trash for electricity and/or ethanol production. The study investigates the trade-off on sugarcane biomass use for energy production: bioelectricity versus 2G ethanol production. The BeWhere mixed integer and spatially explicit model is used for evaluating the choice of technological options. Different scenarios are developed to find the optimal utilization of sugarcane biomass. The study finds that energy prices, type of electricity substituted, biofuel support and carbon tax, investment costs, and conversion efficiencies are the major factors influencing the technological choice. At the existing market and technological conditions applied in the upgraded biorefineries, 300 PJ y À1 2G ethanol could be optimally produced and exported to the EU, which corresponds to 2.5% of total transport fuel demand in the EU. This study provides a methodological framework on how to optimize the alternative use of agricultural residues and industrial co-products for energy production in agro-industries considering biomass supply chains, the pattern of domestic energy demand, and biofuel trade.