M&T Bank ( MTB) rose modestly Thursday after posting a better-than-expected second quarter.

While M&T's quarterly profit of $214 million was flat compared to a year earlier, earnings of $1.95 a share beat analysts' expectations of $1.85. Revenue, excluding a provision for credit losses, rose 5% to $745 million, beating analysts' estimates of $717 million.

"In contrast to the first quarter, M&T experienced a 3-basis-point improvement in our net interest margin and growth in several noninterest income categories, including mortgage banking revenues that were consistent with our historical performance. In addition to revenue growth, operating expenses continued to be well controlled," said M&T's CFO Rene F. Jones.

The company said its net interest margin -- the profit it makes on taking deposits and lending them out again -- rose 1 basis point from a year earlier and 3 basis points from the first quarter to 3.67%.

In the first three months of the year, M&T earnings were hit hard by the troubled mortgage market, particularly in the so-called Alt-A mortgage business -- mortgages made to consumers with imperfect credit histories or without full documentation.

The company lowered earnings guidance for the first quarter after it reduced the value of its Alt-A portfolio and said the demand for repurchase activity for previously sold Alt-A mortgages was increasing.

M&T was not immune to rising credit problems in the second quarter.

M&T's loans classified as "nonperforming" nearly doubled from a year earlier and rose 8% from the first quarter to $296 million. Net charge-offs of $22 million in the quarter were more than double that of the year-earlier quarter.

The company said the rise in nonperforming loans from the first quarter was primarily due to a $34 million loan to a residential home builder and developer in the Mid-Atlantic region.

A growing theme that will be watched carefully in as banks discuss second-quarter earnings results is the severity of commercial problem loans -- particularly those made to homebuilders and other real estate loans -- in light of a sour housing market.

Already three banks -- Huntington Bancshares ( HBAN ), Independent Bank ( IBCP) and Citizens Republic ( CRBC ) have warned that second-quarter earnings would come in short due to credit charges and higher provision expenses to cover loans gone bad in their commercial and real estate portfolios. All three banks attributed the loss to the deteriorating housing market in Michigan.

Bank stocks overall have suffered this year fueled by a shakeout in the subprime mortgage industry.

Many lenders that offered mortgages to consumers with poor credit histories received a sharp blow to earnings in the first quarter from rising delinquencies and defaults as well as the necessity to make early repurchases of loans sold to brokers for securitization.

Dozens of other lenders to subprime borrowers went belly-up this spring. One of the largest subprime lenders that went bankrupt was New Century Financial.

In the second quarter, Keefe, Bruyette & Woods said its KBW Regional Banking Index had an even worse performance of -3.8% in the quarter.

"The main issue to emerge in second quarter will be increased concerns over homebuilder exposure," writes Keith Horowitz, an analyst at Citigroup, in a note. "One of the main engines of growth for the mid- and small-cap banks have been the residential home construction portfolios. We are starting to see increased builder bankruptcies, and expect this to be the primary driver of higher nonperforming assets in second quarter."

But M&T said it is not overly concerned about the rise in net charge-offs.

"Consistent with our expectations, loan charge-off rates have risen although they are still well below historical norms," Jones said.

In the weeks ahead, investors will be keeping an eye on the credit issues. In the Midwest, observers say National City ( NCC) and Fifth Third ( FITB ) could surprise investors with credit problems similar to those of Huntington and Independent Bank.

"National City does have exposure to Michigan and Ohio markets and was fairly aggressive in growing its construction portfolio, so we expect some weakness," Citi's Horowitz writes. "But in the mid-quarter preview it did talk about stable commercial trends, which gives us some comfort that there are not large credit issues in the second quarter."

But Horowitz is optimistic overall about bank earnings this quarter.

"We see limited downside in our universe," he writes. "The overall take coming out of the quarter will be that credit trends are stable for the industry, with some company exceptions that have large homebuilder exposure. As a result, with the recent weakness in bank stock performance and our expectations that the banks credit trends are OK and most banks are likely to meet/beat numbers, we expect that the bank stocks will outperform on second-quarter earnings."

M&T rose $2.68 to $110.41.

If you liked this article you might like

The 10 Best Jobs in America for 2016

The 10 Best Jobs in America for 2016

20 Best Colleges for Campus Food

20 Best Colleges for Campus Food

10 Consumer Stocks With the Highest Earnings Growth Last Quarter

10 Consumer Stocks With the Highest Earnings Growth Last Quarter

5 Stocks Dumped by Hedge Funds Last Quarter

5 Stocks Dumped by Hedge Funds Last Quarter

15 Most Lucrative Jobs in the Tech Industry

15 Most Lucrative Jobs in the Tech Industry