Revenue for the year was $883.6 million, an increase of $198.2 million, or 29%, from $685.4 million in 2011. The increase was primarily due to higher net interest income as well as increased loan production revenue and gain on sale of loans, offset by a decrease in loan servicing income resulting from elevated MSR amortization and a $24.1 million increase to the MSR valuation allowance.
Net Interest Income
For the quarter, net interest income increased by $20.8 million to $147.0 million, from $126.2 million for the third quarter of 2012. This increase was attributed to higher interest income generated by the strong growth in loans and leases HFI, including a $2.5 billion increase in commercial and commercial real estate loans resulting from the acquired BPL loan portfolio as well as growth in our mortgage warehouse finance business, which resulted in a $50.0 million increase in interest income on loans and leases HFI during the quarter. Offsetting this increase was a decline in loans HFS and investment securities average balances and yields. Interest expense increased by $10.2 million during the quarter as we increased longer dated time deposits and borrowings to fund the BPL acquisition.
Net interest margin decreased to 3.56% for the fourth quarter from 3.66% in the third quarter. BPL positively impacted our commercial loan yields and NIM as expected, offset by lower accretion income on our lease financing receivables, the impact of growth in our shorter duration commercial and HFS assets and an increase in interest expense on deposits and borrowings. Excluding the impact of accretion income from our 2010 acquisition of Tygris Commercial Finance Group, Inc., our core net interest margin increased 3 basis points to 3.40% from 3.37% in the third quarter.
For 2012, net interest income was $513.8 million, an increase of $61.5 million, or 14%, compared to 2011. The increase was primarily due to higher average loans, offset by lower asset yields, lower accretion income and higher deposit and other borrowings balances. Net interest margin for 2012 was 3.74% compared to 4.11% in 2011.