We develop a model of the market for federal funds that explicitly accounts for its two distinctive features: banks have to search for a suitable counterparty, and once they meet, both parties negotiate the size of the loan and the repayment. The theory is used to answer a number of positive and normative questions: What are the determinants of the fed funds rate? How does the market reallocate funds? Is the market able to achieve an efficient reallocation of funds? We also use the model for theoretical and quantitative analyses of policy issues facing modern central banks.