This paper presents a contract‐theoretic model in which banks choose prearranged long‐term and spot funding to finance firms' liquidity needs via credit lines. In high liquidity need states, long‐term funding reduces reneging on credit lines, sustains lending, and decreases liquidated firms. Under externalities generated by firm liquidations, banks choose insufficient long‐term funding compared to a social planner. A long‐term funding requirement, such as the Basel III net stable funding ratio, can restore constrained efficiency. The optimal requirement depends on the frequency of high liquidity need states, the value lost upon liquidation, and the excess cost of long‐term funding.