Interest and Dividend Income. Interest and dividend income on a tax equivalent basis decreased $740,000, or 2.0%, to $35.9 million for the three months ended June 30, 2021, compared to $36.6 million for the three months ended June 30, 2020. All adjustable rate products were negatively impacted by the Federal Reserve cuts to the federal funds rate, and although loan origination volume remains strong, lower rates on loan originations also negatively impacted interest and dividend income. For the three months ended June 30, 2021, the components of the decrease were a $637,000 decrease investment income, a $136,000 decrease in interest on loans held for sale, and a $103,000 decrease in interest on other interest earning assets, partially offset by a $136,000 increase in interest on loans. The yield on investment securities decreased 142 basis points. The increase in interest income on loans reflected the $53.3 million, or 1.6%, increase in the average total loan balance, partially offset by a 6 basis points decrease in the average yield on loans. Commercial loans were the primary driver of the average balance growth and residential real estate loans were the primary driver of the decrease in yield . Loan interest income for the three months ended June 30, 2021 included $1.0 million in accretion income from the fair value discount on loans acquired from Coastway Bancorp, Inc., as compared to $1.3 million for the three months ended June 30, 2020. Loan interest income for the three months ended June 30, 2021 also includes $1.3 million in recognition of origination fees on the PPP loans as compared to $518,000 for the three months ended June 30, 2020. The decrease in interest on loans held for sale reflected a lower average balance due to a decrease in residential real estate mortgage loan demand.
Compared to the first six months of 2020, interest and dividend income decreased $2.1 million, or 2.8%, reflecting a $1.9 million decrease in investment income, a $784,000 decrease in other interest-earning assets income, and a $29,000 decrease in total loan income, partially offset by a $611,000 increase in income from loans held for sale. Average investments increased $40.6 million, however, the yield decreased 161 basis points, primarily as a result of accelerated amortization of premiums on mortgage-backed securities. The average of other interest-bearing assets increased $85.1 million, offset by a 83 basis point decrease in yield. The decrease in loan yield was largely offset by the increase in the average balances.
Interest Expense. Interest expense decreased $3.8 million, or 53.2%, to $3.4 million for the three months ended June 30, 2021 from $7.2 million for the three months ended June 30, 2020. The decrease resulted from a $3.5 million decrease in interest expense on deposits and a $314,000 decrease in interest expense on FHLB borrowings. The decrease in interest expense on deposits reflected a 56-basis point decrease in the cost of interest-bearing deposits, partially offset by $238.6 million, or 9.0%, increase in the average balance of interest-bearing deposits. The cost of deposit funds was significantly impacted by falling rates and the deposit mix, as customers moved to more liquid options. The average balance of savings accounts increased $275.9 million, or 32.7%, and the average cost of savings accounts decreased 23 basis points. The cost of money market deposits decreased 39 basis points to 0.20% for the three months ended June 30, 2021 compared to the three months ended June 30, 2020, and the average balance increased 3.2%. Average certificates of deposit decreased by $140.8 million, or 19.3%, and the cost of certificates of deposits was 0.62% for the second quarter of 2021 compared to 1.91% for the second quarter of 2020. The decrease in interest expense on FHLB advances resulted from a $161.9 million, or 62.6% decrease in average balances partially offset by a 89-basis point increase in the cost of FHLB advances.
Compared to the first six months of 2020, interest expense decreased $10.5 million, or 59.5%, to $7.2 million from $17.6 million reflecting similar trends discussed in the quarter over quarter results. Average interest bearing deposits increased $256.3 million, or 9.8%, and the cost of interest-bearing deposits decreased 77 basis points year over year. The decrease in interest expense on FHLB borrowings is due to the average balance decrease of $150.4 million, or 60.2%, partially offset by a 50 basis point increase in the cost of borrowed funds.
Net Interest and Dividend Income. Net interest and dividend income on a tax equivalent basis increased $3.1 million, or 10.4%, to $32.5 million for the three months ended June 30, 2021 from $29.5 million for the three months ended June 30, 2020, primarily as a result of deposit account repricing and commercial loan growth. The tax equivalent net interest spread increased 18 basis points to 2.93% for the three months ended June 30, 2021 from 2.75% for the three months ended June 30, 2020, and net interest margin on a tax equivalent basis increased 6 basis points to 3.06% for the three months ended June 30, 2021 from 3.00% for three months ended June 30, 2020.
Compared to the first six months of 2020, net interest and dividend income increased $8.4 million, or 15.0%, to $64.6 million from $56.2 million. The tax equivalent net interest spread increased 30 basis points to 2.96% for the six months ended June 30, 2021 from 2.66% for the six months ended June 30, 2020, and net interest margin on a tax equivalent