(Adds Bowman comments, data on troubled assets, loan loss provisions)

The U.S. thrift industry on Wednesday reported its first profit since the third quarter of 2007, earning a slender total of $4 million in the second quarter, the Office of Thrift Supervision said.

The second-quarter figure compared with a whopping loss of $1.62 billion in the first quarter of 2009, which was revised on Wednesday from a previously reported loss of only $47 million.

The OTS, which largely regulates mortgage lenders, said the small profit was primarily due to higher net interest margins, lower provisions for loan losses and higher fee income.

However, the agency also said the number of problem thrifts grew to 40 at the end of the second quarter, from 31 the previous quarter.

Despite some encouraging signs, the industry's performance remained uneven, said John Bowman, acting director of the OTS. The bottom line is the industry is not out of the woods yet.

Bowman noted that the number of troubled assets grew during the second quarter to 3.52 percent of all thrift assets, compared with 3.35 percent the prior quarter.

Thrifts also continued to set aside large amounts of money to protect against deteriorating loans. Loan loss provisions declined slightly to $4.7 billion during the second quarter, but were still the sixth-highest on record, the OTS said.

The agency said the uneven financial picture reflected the nation's weak job market and a generally weak economic environment. (Reporting by Karey Wutkowski and Steve Eder, editing by Gerald E. McCormick and Maureen Bavdek)