MILWAUKEE (AP) — Private mortgage insurer MGIC Investment Corp. surprised Wall Street on Tuesday by posting its first quarterly profit in three years as its foreclosure-related losses dropped.

The results sent the company's stock up as much as 11 percent on heavy trading volume. But MGIC cautioned that it expects its foreclosure-related losses to decline more modestly in the second half of the year, as most of the benefit of the government's Home Affordable Modification Program (HAMP) has been realized.

For the three months ended June 30, MGIC reported net income of $24.6 million, or 13 cents per share, compared with a loss of $339.8 million, or $2.74 per share, for the 2009 second quarter. The company's losses fell by more than half to $320.1 million, from $769.6 million in same period last year, mainly due to a drop in home foreclosures.

Analysts polled by Thomson Reuters, on average, had expected a loss of 63 cents per share.

Revenue slipped to $406.4 million, from $454.5 million last year but easily topped analysts' average estimate of $353.8 million. Net premiums written dipped to $295.3 million from $330.4 million for the same period last year.

As of June 30, the percentage of loans that were delinquent, excluding bulk loans, totaled 15 percent. That's up from 12 percent a year ago but a slight drop from 15.46 percent at Dec. 31. Including bulk loans, 18 percent of loans were delinquent, compared with 18.41 percent at Dec. 31.

MGIC shares gained 73 cents, or 9.3 percent, to close at $8.55, on volume more than twice the normal daily average. Shares jumped as high as $8.72 during the session.

In a statement, MGIC warned it currently expects to book higher losses for the second half of 2010 than what it reported for the first half of the year, with the industry's 2006 and 2007 books particularly affected. Chief Financial Officer Mike Lauer noted on a conference call with analysts that MGIC's 2009 book is performing very well, as is the second half of 2008, which is very positive. The question is whether the drop in foreclosure inventory will be as significant in the second half of the year as it was in the first.

Larry Pierzchalski, executive vice president of risk management, agreed that the industry is coming into a weaker cure part of the year, and said "most of the benefit of HAMP is behind us."

During the second quarter about two-thirds of the company's modifications were HAMP, and one third were non-HAMP. That mix was up from 75 percent vs 25 percent in the first quarter, respectively.

Chairman and CEO Curt Culver said that on the revenue side he continues to be discouraged by MGIC's lack of competitiveness against the Federal Housing Administration, given that they haven't changed premium rates despite losing money. MGIC's new insurance written was $2.7 billion in the latest quarter, down from $5.9 billion the year before.

However, he said that through the federal omnibus bill FHA will change the premium rate structure, "which will make our industry very competitive relative to the FHA and should ignite new insurance written next year."