American International Group Inc , the insurer that received about $180 billion of federal bailouts, posted its first profit in seven quarters and shares rose 9 percent.

The second-quarter net profit attributable to common shareholders was $311 million, but the quarterly profit attributable to AIG was $1.8 billion, or $2.30 a share, compared with a net loss of $5.4 billion, or $41.13 a share, in the year-earlier quarter.

On an adjusted basis, the company had income of $2.57 a share, beating analyst expectations of $1.33 a share, according to Reuters Estimates.

AIG's shares were up $2.13 at $24.66 in trading before U.S. markets opened.

Once the world's largest insurer, AIG nearly collapsed last year because of its exposure to credit default swaps, which left it on the hook for tens of billions of dollars of payouts.

(Reporting by Lilla Zuill; Editing by Derek Caney)