A flexible framework for estimating the technical and unused biomass potential for biogas production with high spatial resolution has been developed to integrate biomethane into future energy systems. By classifying agricultural biomass into non-competitive biomass (NCB), livestock-competitive biomass (LCB), and food/feed-competitive biomass (FCB), the model accounts for their competing uses in livestock production and food security. Applied to Bavaria, the analysis covers 2,229 municipalities, using data from agricultural enterprises, biomass yields, and biogas production. The results show an unused methane potential of 1.58⋅109 m3 from agricultural NCB and LCB, potentially covering 12.2 % of Bavaria’s natural gas consumption in 2021. A Monte Carlo simulation was performed to account for uncertainty in the underlying data and to perform a sensitivity analysis. The results highlight that agricultural policy decisions, particularly those affecting livestock production, significantly influence the technical biogas potential: Decreases in manure and slurry formation may reduce the potential, but this could be offset by the availability of unused biomass from livestock feed, depending on policy choices. The presented framework may be used for different regions given availability of data, while the results offer valuable insights for policymakers and stakeholders for developing the biogas sector and its integration into a renewable energy system in the studied region.