NEW YORK - John Malone's Liberty Media Corp has agreed to lend $530 million to Sirius XM Radio Inc in exchange for a 40 percent equity stake, saving the satellite radio provider from possible bankruptcy and sending its shares up 100 percent.

The deal also helps Sirius Chief Executive Mel Karmazin fend off a potential takeover bid by Charles Ergen's EchoStar Corp, which has purchased hundreds of millions of Sirius's total debt of about $3.25 billion.

Under the agreement, Liberty would first provide a $280 million senior secured loan to Sirius XM, of which $250 million would be funded on Tuesday to help the satellite radio company repay $171.6 million in convertible notes maturing today.

Then Liberty would provide another $150 million loan to XM Satellite Radio, Sirius XM's wholly owned subsidiary, and also purchase up to $100 million of XM's credit facilities.

Once the loans are completed, Sirius XM would issue Liberty 12.5 million shares of preferred stock convertible into 40 percent of common stock.

Liberty, which owns a controlling stake in satellite TV provider DirecTV Group Inc, would also receive seats on Sirius XM's board, and expects Malone and Liberty Chief Executive Greg Maffei to join the board.

The deal comes after days of talks between the two companies as pressure mounted on Karmazin to raise funds to address some $1 billion in debt due this year.

Karmazin said in a statement that he was pleased with the agreement particularly in light of today's challenging credit markets and that it would enhance Sirius XM's capital structure and financial flexibility.

It was not clear what Liberty's plans are for Sirius XM, but analysts noted that Malone was receiving a lucrative 15 percent interest rate on its $280 million, which matures in December 2012.

We think that John Malone and Charlie Ergen's strategies are different. We think that Charlie Ergen's strategy may have been more about creating a broader strategic play in wireless services as he has attempted mobile video before, said Thomas Eagan, analyst at Collins Stewart.

For John Malone it's more of a financial investment, especially with a 15 percent rate. He had this venture fund with cash available and he figured this was a worthwhile investment.

Sirius has been trying to refinance debt since its acquisition of rival satellite radio provider XM, which was approved last July.

But tight credit markets and the weak near-term outlook for satellite radio -- due to the slowdown in retail demand and downturn in the car industry where satellite radio gains most of its news subscribers -- has made that tough.

Maffei, however, said Liberty has been impressed with Sirius's operations and management team. Sirius XM's ability to grow subscribers and revenue in a difficult financial and auto market is indicative of how listeners view this as a must have service, Maffei said in a statement.

Sirius said the deal does not constitute a change in control for the company under its outstanding debt instruments, and is not subject to approval of the U.S. Federal Communications Commission.

Shares of Sirius doubled to 21 cents in early trading on the Nasdaq.

(Reporting by Franklin Paul, Yinka Adegoke and Tiffany Wu, editing by Dave Zimmerman)