This paper examines optimal policy in a macroeconomic model with collateral constraints. Binding collateral constraints yield inefficient competitive equilibrium allocations because they distort the optimal utilization of real resources. I identify the set of policy instruments that can be used by a Ramsey planner to achieve the first-best and the second-best (i.e., constrained planner's) allocations. A system of distortionary taxes on capital and labor income, along with direct lump-sum transfers among borrowers and lenders replicates the first-best outcome. The tax rates correct for the marginal distortions, whereas the direct lump-sum transfers perform income redistributions among the agents. In absence of direct lump-sum transfers, the distortionary taxes have an additional role, i.e., to perform implicit income transfers, and only second-best outcomes are attainable. I also derive the optimal policy in response to real and financial shocks, and show how the policy recommendations differ depending on the set of policy instruments available.