GlaxoSmithKline expects to record a legal charge of 1.57 billion pounds ($2.4 billion) for the second quarter after settling the substantial majority of claims relating to its controversial diabetes pill Avandia.

The move, designed to clear the decks of outstanding legal issues, will wipe out most of the drugmaker's expected earnings for the three months to June but leaves it better placed to grow profits in future.

The British drugmaker said on Thursday the charge would cover not only settlements for Avandia but also other long-standing legal cases, including an investigation into its former factory at Cidra in Puerto Rico and anti-trust litigation over antidepressant Paxil.

The charge will cost 1.35 billion pounds after tax.

News of the hefty charge -- equal to about 2.5 percent of Glaxo's market value -- initially dampened an anticipated rally in the shares after a U.S. panel voted to keep Avandia on the market but with new warnings on heart risks.

However, the stock gained ground in morning trade and was up 1.8 percent by 1030 GMT (6:30 a.m. EDT), outperforming a 0.7 percent advance in the European drugs sector <.SXDP> and matching gains overnight in New York .

Some people might baulk at the size of the charge but probably most will say this is putting it all behind the company, so we can now look to the continuing business and view the stock on a more rational basis, said Deutsche Bank analyst Mark Clark.

The big legal hit will slash second-quarter earnings per share by more than 26 pence, according to analysts, wiping out most of the group's profit. Prior to the news, the consensus EPS forecast for the period had been 29.5 pence, according to Thomson Reuters data.

It is a negative in the short term but longer term it is a positive because from here we anticipate that EBIT (earnings before interest and tax) will actually go up 2 to 5 percent based on the company running these charges through now, said UBS analyst Gbola Amusa.

They are closing the book on uncertainties upfront, which makes for a cleaner organization.

FALLING AVANDIA SALES

Glaxo did not specify the amount it was setting aside to settle liability claims over Avandia, arguing settlement terms were confidential.

Initially, analysts had feared it might have to spend as much as $6 billion to resolve thousands of U.S. Avandia claims. But the favorable panel vote and recent reports of modest settlements means some now see a bill of under $1 billion.

Avandia was once Glaxo's second-biggest drug, with sales of around $3 billion a year. Since 2007, however, it has been in decline after it was first linked to heart attacks. It sold just $1.2 billion in 2009.

Those sales are expected to keep falling as new restrictions on its use are introduced. But investor concerns have been focused more on the company's legal liability than on the relatively modest impact of Avandia to the sales and profit lines.

Glaxo said the resolution of the various disputes was a significant step in clearing legal uncertainties.

This represents a substantial proportion of GSK's outstanding litigation. This progress is helping us to reduce financial uncertainty and risk for shareholders, Dan Troy, the drugmaker's general counsel, said in a statement.

While it did not break out the other components of the charge, Glaxo did disclose that the agreement in principle over Cidra was for a total of 500 million pounds.

A company spokeswoman said the latest 1.57 billion pounds charge would be in addition to the company's current balance sheet legal provision of 2.3 billion pounds.

Avandia also faces scrutiny from the European Medicines Agency, which has launched a new review into the drug's risks and benefits and will discuss the matter July 19-22 in London.

(Editing by Dan Lalor and Michael Shields)

($1 = 0.6580 pound)