We provide evidence that banks distort the composition of credit supply in order to comply with ratio-based capital requirements in times of economic distress. An unexpected intervention by the European Banking Authority provides a natural experiment to study how banks respond to falling below minimum required capital ratios during an economic downturn. We show that affected banks respond by cutting lending but also by reallocating credit to distressed firms with underreported loan losses. We develop a method to detect underreported losses using loan-level data. The credit reallocation leads to a reallocation of inputs across firms. We calculate that the resulting increase in input misallocation accounts for about 22 percent of the decline in productivity in Portugal in 2012.