We present a generic algorithm for automating sedimentary basin reconstruction. Automation is achieved through the coupling of a two-dimensional thermotectonostratigraphic forward model to an inverse scheme that updates the model parameters until the input stratigraphy is fitted to a desired accuracy. The forward model solves for lithospheric thinning, flexural isostasy, sediment deposition, and transient heat flow. The inverse model updates the crustal- and mantle-thinning factors and paleowater depth. Both models combined allow for automated forward modeling of the structural and thermal evolution of extensional sedimentary basins. The potential and robustness of this method is demonstrated through a reconstruction case study of the northern Viking Graben in the North Sea. This reconstruction fits present stratigraphy, borehole temperatures, vitrinite reflectance data, and paleowater depth. The predictive power of the model is illustrated through the successful identification of possible targets along the transect, where the principal source rocks are in the oil and gas windows. These locations coincide well with known oil and gas occurrences. The key benefits of the presented algorithm are as follows: (1) only standard input data are required, (2) crustal- and mantle-thinning factors and paleowater depth are automatically computed, and (3) sedimentary basin reconstruction is greatly facilitated and can thus be more easily integrated into basin analysis and exploration risk assessment. Lars Helmuth Rüpke is a professor for sea-floor resources at the research cluster “The Future Ocean” at IFM-GEOMAR in Kiel, Germany. Before moving to Kiel, he was a senior researcher at Physics of Geological Processes at Oslo University, Norway. His present research focuses on passive margins, sedimentary basins, and fluid migration pattern through the Earth's crust. Stefan Markus Schmalholz is a senior researcher and lecturer at the Geological Institute of the Eidgenössische Technische Hochschule (ETH) Zurich, Switzerland. His present research focuses on folding and necking instabilities in rocks, low-frequency wave propagation in porous rocks, and numerical modeling of rock deformation. He holds a Ph.D. in natural sciences and a diploma in earth sciences both from ETH Zurich. Daniel Walter Schmid is a senior researcher and coordinator of the microstructures group at the Physics of Geological Processes at Oslo University, Norway. His present research focuses on small-scale rock deformation, coupling between chemical reactions and deformation, and the development of efficient numerical models. He holds a Ph.D. in geology from the ETH Zurich, Switzerland. Yuri Y. Podladchikov is a professor at Oslo University and Physics of Geological Processes.