Interest income on investment securities and interest-bearing deposits in banks increased $740,000, or 85.3% to $1.6 million during the three months ended March 31, 2022, compared to $868,000 for the three months ended March 31, 2021, primarily due a $68.1 million increase in the average balance of investment securities, as well as a higher average yield earned on investment securities. The average yield on investment securities increased 43 basis point to 3.15% for the three months ended March 31, 2022 compared to 2.72% for the same period prior year.
Interest expense. Interest expense increased $264,000, or 12.1%, to $2.5 million for the three months ended March 31, 2022 compared to $2.2 million for the three months ended March 31, 2021. The increase was due to the $293.7 million increase in the average balance of deposits. Total average interest bearing liabilities increased $289.0 million, or 23.0%, to $1.5 billion for the three months ended March 31, 2022, compared to $1.3 billion for the three months ended March 31, 2021. The average rate paid on interest bearing liabilities decreased by seven basis points to 0.64% for the three months ended March 31, 2022, compared to 0.71% for the same period prior year.
Interest expense on deposits increased $264,000, or 24.9%, to $1.5 million for the three months ended March 31, 2022 compared to $1.2 million for the three months ended March 31, 2021, primarily due to increases in the average balance in all interest bearing deposit categories. The average balance of deposits totaled $2.2 billion for the three months ended March 31, 2022, compared to $1.9 billion for the same quarter a year ago, respectively. The average rate paid on interest bearing deposits decreased by one basis point to 0.41% for the three months ended March 31, 2022, from 0.42% for the three months ended March 31, 2021. The overall average cost of deposits for the three months ended March 31, 2022, increased to 0.27%, compared to 0.26% for the three months ended March 31, 2021. The average balance of noninterest bearing deposits increased $61.9 million, or 8.51%, to $789.1 million for the three months ended March 31, 2022 compared to $727.4 million for the same period in 2021.
Interest expense on borrowings was $982,000 for both the three months ended March 31, 2022 and 2021, due to decreases in borrowings outstanding offset by increases in the average cost of borrowings. The average balance of borrowings outstanding decreased $4.8 million to $72.0 million during the three months ended March 31, 2022, compared to $76.7 million during the three months ended March 31, 2021. The average cost of borrowing increased to 5.53% for the three months ended March 31, 2022, compared to 5.19% for the three months ended March 31, 2021.
Net interest income and net interest margin. Net interest income increased $4.3 million, or 23.6%, to $22.4 million for the three months ended March 31, 2022, compared to $18.1 million for the three months ended March 31, 2021. The increase in net interest income primarily was due to increases in interest income on loans and, to a lesser extent, investment securities due to increases in the average balances of these portfolios, partially offset by lower recognition of deferred loan fee income from SBA loan forgiveness related to PPP loans.
The average yield on interest earning assets for the three months ended March 31, 2022 was 4.03%, a 12 basis point increase from 3.91% for the three months ended March 31, 2021, primarily due to higher market interest rates, while the average cost of interest bearing liabilities for the three months ended March 31, 2022 decreased to 0.64%, or seven basis points from 0.71% for the three months ended March 31, 2021.
The annualized net interest margin for the three months ended March 31, 2022 was 3.63%, compared to 3.49% for first quarter of 2021. The comparable quarter over quarter increase in net interest margin primarily reflects an improved mix of interest-bearing assets, including increased balances of higher yielding loans and investment securities available for sale. During the quarter, the recognition of deferred loan fees related to PPP loans and accretion on acquired loans, also had a positive impact on the net interest margin. PPP loans are originated at an interest rate of 1%, although the effective yield is higher as a result of the origination fees paid to us by the SBA. The average yield on PPP loans was 5.89%, including the recognition of deferred fees, resulting in a positive impact to the net interest margin of eight basis points during the three months ended March 31, 2022, compared to 4.51% with a positive impact of three basis points during the comparable periods in 2021. The impact of PPP loans on net interest margin will change during any period based on the volume of prepayments or amounts forgiven by the SBA as certain criteria are net, but will cease completely after the maturity of the loans. Accretion of acquisition accounting discounts on loans and the recognition of revenue from acquired loans in excess of discounts increased our net interest margin by 21 basis points during the three months ended March 31, 2022 and 17 basis points during the three months ended March 31, 2021.