When external finance is costly, liquid funds provide corporations with instruments to absorb and react to shocks. Making optimal use of liquid funds means transferring them to times and states where they are most valuable. We examine the determinants of corporate liquidity management in a dynamic model where stochastic investment opportunities and cash shortfalls provide liquidity needs. Firms can transfer liquidity across time using cash and across states drawing on credit lines subject to debt capacity constraints. We generate empirical and quantitative predictions by means of calibration. Small and constrained firms use cash to provide liquidity to fund investment opportunities, while large and unconstrained firms manage their liquidity needs by means of credit lines. In the time series, equity issuances are used to replenish cash balances, and credit lines to fund unanticipated investment opportunities. We find strong support for our predictions in the data. Overall, the model provides a quantitatively and empirically successful framework explaining corporate investment, financing and liquidity policies and the joint occurrence of cash, debt and credit lines in the presence of capital market imperfections.