This paper contributes to the body of knowledge on search frictions in credit markets by demonstrating their ability to explain why the net interest margins of banks behave countercyclically. During periods of expansion, a fall in the net interest margin proceeds from two mechanisms: (i) lenders accept that they must finance entrepreneurs who have lower productivity; (ii) the liquidity of the credit market rises, which simplifies access to loans for entrepreneurs and thereby reinforces their threat point when bargaining the interest rate of the loan.