Reliable estimates of indirect economic losses arising from natural disasters are currently out of scientific reach. To address this problem, we propose a novel approach that combines a probabilistic physical damage catastrophe model with a new generation of macroeconomic agent-based models (ABMs). The ABM moves beyond the state of the art by exploiting large data sets from detailed national accounts, census data, and business information, etc., to simulate interactions of millions of agents representing each natural person or legal entity in a national economy. The catastrophe model introduces a copula approach to assess flood losses, considering spatial dependencies of the flood hazard. These loss estimates are used in a damage scenario generator that provides input for the ABM, which then estimates indirect economic losses due to the event. For the first time, we are able to link environmental and economic processes in a computer simulation at this level of detail. We show that moderate disasters induce comparably small but positive short- to medium-term, and negative long-term economic impacts. Large-scale events, however, trigger a pronounced negative economic response immediately after the event and in the long term, while exhibiting a temporary short- to medium-term economic boost. We identify winners and losers in different economic sectors, including the fiscal consequences for the government. We quantify the critical disaster size beyond which the resilience of an economy to rebuild reaches its limits. Our results might be relevant for the management of the consequences of systemic events due to climate change and other disasters.