A central prediction of open economy models with a pecuniary externality due to a collateral constraint is that the unregulated economy overborrows relative to what occurs under optimal policy. A maintained assumption in this literature is that house-holds borrow directly from foreign lenders. This paper shows that if foreign lending is intermediated by domestic banks and the government can pay interest on bank reserves and impose capital controls, the unregulated economy underborrows. The optimal bank reserve policy is countercyclical. By increasing bank reserves during contractions, the government acts as a lender of last resort to collateral-constrained households.