increased $7.1 million, primarily as a result of higher market interest rates, higher utilization of borrowings and a shift in deposit mix from transactional accounts to higher cost CDs.
For the six months ended June 30, 2023, net interest income increased $14.8 million to $62.2 million, from $47.5 million for the six months ended June 30, 2022 for the same reason as for the three-month comparison described above, with an increase in interest income of $27.9 million and a decrease in interest expense of $13.1 million.
NIM (annualized) increased 27 basis points to 4.66% for the three months ended June 30, 2023, from 4.39% for the same period in the prior year, and increased 36 basis points to 4.68% for the six months ended June 30, 2023, from 4.32% for the six months ended June 30, 2022. The increase in NIM for the three and six months ended June 30, 2023 compared to the same periods in 2022, reflects new loan originations at higher market interest rates and variable rate interest-earning assets repricing higher following recent increases in market interest rates. The benefit from higher rates and interest earning assets were partially offset by rising deposit and borrowing costs. Increases in average balances of higher costing CDs and borrowings placed additional pressure on the NIM.
The average total cost of funds, including noninterest-bearing checking, increased 105 basis points to 1.48% for the three months ended June 30, 2023, from 0.43% for the three months ended June 30, 2022. This increase was predominantly due to the rise in cost for market rate for deposits. The average cost of funds increased 99 basis points to 1.40% for the six months ended June 30, 2023, from 0.41% for the six months ended June 30, 2022, also reflecting increases in market interest rates over last year. Management remains focused on matching deposit/liability duration with the duration of loans/assets where appropriate.
For the three and six months ended June 30, 2023, the provision for credit losses on loans was $1.1 million and $3.4 million, respectively, compared to $1.6 million and $2.5 million for the three and six months ended June 30, 2022. The provision for credit losses on loans reflects an increase in total loans receivable and net charge-offs in indirect home improvement and marine loans.
During the three months ended June 30, 2023, net charge-offs totaled $651,000, compared to $16,000 for the same period last year, primarily due to increased net charge-offs of $476,000 in indirect home improvement loans and $152,000 in marine loans. Net charge-offs totaled $1.1 million during the six months ended June 30, 2023, compared to $280,000 during the six months ended June 30, 2022. This increase was primarily due to net charge-off increases of $585,000 in indirect home improvement loans and $199,000 in marine loans. Net charge-offs have been steadily increasing over the last several years primarily attributable to volatile economic conditions.
Noninterest income increased $478,000, to $4.8 million, for the three months ended June 30, 2023, from $4.4 million for the three months ended June 30, 2022. The increase reflects a $584,000 increase in service charges and fee income, primarily as a result of less amortization of mortgage servicing rights reflecting increased market interest rates and increased servicing fees from non-portfolio serviced loans, partially offset by a $119,000 decrease in the gain on sale of loans. Noninterest income decreased $179,000, to $10.1 million, for the six months ended June 30, 2023, from $10.2 million for the six months ended June 30, 2022. This decrease was primarily the result of a $2.5 million decrease in gain on sale of loans, partially offset by a $1.7 million increase in service charges and fee income and $630,000 increase in other noninterest income.
Noninterest expense increased $5.3 million to $24.2 million for the three months ended June 30, 2023, from $18.9 million for the three months ended June 30, 2022. The increase in noninterest expense was primarily a result of a $1.8 million increase in salaries and benefits largely due to the Branch Acquisition and growth in FTEs. Other increases included $1.3 million in operations expense, $851,000 in amortization of CDI, $406,000 in FDIC