We construct a model to clarify the mechanism by which the lender of last resort (LLR) can prevent bank runs. In our model, a bank has both the function of facilitating payments in which inside money is settled using outside money and the function of financial intermediation using a deposit contract. The deposit contract might lead to a bank run, and might even contribute to an efficient allocation. Therefore, to consider the liquidity supply by the LLR, we introduce the deposit contract as a factor of instability in the banking model. We show that the LLR can assist in the recovery of both the efficiency and stability of the financial system. JEL Classification Numbers: E52, E58.