John Malone’s Liberty Media Corp. agreed to buy about 27 percent of Charter Communications Inc. for about $2.62 billion, betting that the formerly bankrupt cable company can thrive in an era of digital services.

Liberty will pay $95.50 apiece for about 26.9 million shares and 1.1 million warrants for Charter’s private-equity investors Apollo Global Management, Oaktree Capital Management and Crestview Partners, according to a statement today. The transaction is expected to close by mid-May.

Charter, the fourth-largest U.S. cable operator, has been taking advantage of improving cash flow to refinance debt and add customers through the acquisition of Cablevision Systems Corp.’s Optimum West. Its shares have almost tripled since the end of 2009, when it emerged from bankruptcy protection with the deal that gave the private-equity firms their stakes.

“We are pleased with Charter’s market position and growth opportunities and believe that the company’s investments in its high-capacity digital network, which provides digital HD and on- demand television, high-speed data and voice, will benefit its customers and shareholders alike,” Malone, Liberty’s chairman, said in the statement.

Charter’s stock rose 8.8 percent to $98.04 at the close in yesterday after reports of the deal first surfaced. Liberty’s offer represents a 6 percent premium over the stock’s trading price before the news broke. The shares gained an additional 1.2 percent to $99.25 at 9:34 a.m. today in New York, the highest level since the bankruptcy.

As part of the agreement, Liberty will name four directors to Charter’s board. The company expects to designate Malone; Liberty Chief Executive Greg Maffei; Liberty Global Inc. Executive Vice President Nair Balan; and Michael Huseby, chief financial officer of Barnes & Noble Inc., another company backed by Liberty. Current directors Stan Parker, Darren Glatt, Bruce Karsh and Edgar Lee -- who are affiliated with Charter’s private-equity backers -- will resign from the board.

Liberty also agreed not to attempt to take control of Charter. Under the terms of the deal, it won’t increase its ownership above 35 percent until January 2016 and 40 percent thereafter. Liberty also said it won’t start a proxy fight for more board seats, so long as its directors maintain their positions.

While Malone’s Liberty Global has 19.6 million pay-TV, Internet and phone customers, mostly in Europe, and the billionaire directly holds a 4.8 percent stake in satellite-TV company DirecTV, his U.S. cable investments have been limited since he sold Tele-Communications Inc. to AT&T Corp. in 1999. Liberty Media holds an undisclosed stake in Time Warner Cable Inc., the second-biggest U.S. cable company, according to the annual report of Malone’s company.

Started by Paul Allen, a Microsoft Corp. co-founder, in 1993, Charter filed for bankruptcy protection in March 2009 after becoming overwhelmed by more than $21 billion in debt. Allen’s stake dropped to 35 percent when Charter emerged with about $8 billion less debt. He has since sold almost all his remaining shares, according to regulatory filings.

The company agreed this year to acquire Optimum West for $1.63 billion, gaining more than 360,000 customers in Montana, Wyoming, Colorado and Utah. Charter currently serves about 5 million customers in 25 states.