Chinese Internet entrepreneur Jack Ma is buying back up to half of a 40 percent stake in his Alibaba Group from Yahoo Inc for $7.1 billion, in a deal that moves the Chinese e-commerce leader closer to a public listing.

Under the agreement, Yahoo will sell half its stake in Alibaba for at least $6.3 billion in cash and up to $800 million in new Alibaba preferred stock. The deal, announced in a joint statement on Monday, caps years of often acrimonious talks over how Alibaba could reclaim some or all of the 40 percent stake that Yahoo bought for about $1 billion in 2005.

While Alibaba founder Ma had a strong personal rapport with Jerry Yang, Yahoo's co-founder who led the initial investment in Alibaba, ties between the two firms soured when Yang was ousted and replaced as CEO by Carol Bartz.

Relations were also complicated by a spat over the Chinese group's payment unit Alipay, and Yahoo's attempt to appoint more directors at Alibaba. Negotiations over a complex deal for Ma, who owns close to 7.5 percent of Alibaba, to buy back most of the Yahoo stake for up to $9 billion faltered earlier this year over valuation.

Yahoo, which has come under fire from shareholders for failing to take aggressive action to reverse a decline in advertising revenue in the face of competition from Google Inc and Facebook, will hand most of the sale proceeds, after tax, to its stockholders.

"For Yahoo it's a decent compromise, they were never going to keep all the 40 percent stake and expect to see these guys IPO. I think they sold it off at a pretty reasonable valuation," said Michael Clendenin at RedTech Advisors in Shanghai. "Yahoo still has a lot of bigger problems ahead of them, I mean, they are a portal so they're going the way of the dodo bird."

"Credit to Jack Ma, he's a wheeler and dealer and he got a very good deal on this one," he added.

A source familiar with the deal said Yahoo built in incentives for Alibaba, which operates the popular Chinese online marketplace Taobao, to hold an initial public offering by end-2015. Alibaba would buy back half of Yahoo's remaining stake - a 10 percent holding - at the IPO price or allow Yahoo to sell those shares in the offering before end-2015.

Alibaba Group, valued at $30-35 billion, listed its Alibaba.com unit in 2007, and in February agreed to buy it out, with Ma saying a group IPO would reward employees for their service.

"The valuation is reasonable ... but I don't think this is going to affect the IPO strategy," said Elinor Leung, analyst at CLSA. "I don't think the IPO is going to be imminent, meaning this year. Net-net this is going to be positive for Yahoo because you cash out on half the stake, but Yahoo's main worry is their U.S. business."

Alibaba said it would raise the money through a mix of cash, debt and equity. Sources said the group was in talks with existing shareholders including Singapore state investor Temasek Holdings to raise about $2.3 billion in equity to part-finance the deal. Alibaba was not immediately available to comment and a Temasek spokesman declined to comment.

Temasek bought shares from Alibaba employees in September in a tender offer in which DST Global, Silver Lake and Yunfeng Capital also took part. According to Basis Point, a Thomson Reuters publication, Alibaba is likely to increase a $3 billion loan for taking its listed unit private to $4 billion.

Alibaba has long been the dominant player in China's booming e-commerce sector, but the landscape in the world's biggest Internet market is evolving, with Amazon.com, Dangdang and 360buy emerging as tough competitors. Taobao has around 90 percent market share in China's consumer-to-consumer online trading and more than 53 percent of the business-to-consumer market.

SIMPLIFYING YAHOO

Yahoo's Alibaba stake and its 35 percent holding in Yahoo Japan, which it jointly owns with Softbank Corp , are considered the crown jewels of the struggling U.S. Internet company. Some investors have said Yahoo should monetize some of those holdings and return the proceeds to shareholders. Softbank owns around 30 percent of Alibaba.

Analysts have said selling down the Asian assets would raise cash for Yahoo and simplify its structure, making it easier for investors to value its core U.S. operations. Yahoo said it would return "substantially all" of the after-tax cash proceeds from the deal to its stockholders, increasing a planned share buyback authorisation by $5 billion.

The deal marks an important accomplishment and an early sign of progress for Yahoo interim CEO Ross Levinsohn, the fifth person to step into the top job in the past five years at the company, which have seen falling revenue, layoffs, management reorganizations and executive departures.

Many analysts expect Levinsohn - who follows Scott Thompson, who stood down earlier this month after he was accused of overstating his qualifications, and Bartz, who was fired last September - to re-orient the company around its media properties including Yahoo Sports and Yahoo Finance, while focusing less on expensive tech efforts such as search and social networking.

Finalising a deal with Alibaba could remove a distraction, allowing Levinsohn to focus on a comeback plan, while potentially earning goodwill from investors frustrated by missteps and poor performance.

"For Yahoo, this is something that needed to get done because Alibaba was having a bit of an issue with ... the group being so dominantly owned by foreign entities," Nomura Securities analyst Jin Yoon told Reuters.

"The China asset was kind of their crown jewel so I don't actually expect Yahoo to fully depart from China and I do expect Yahoo will have some sort of remaining involvement with Alibaba Group."

Sunnyvale, California-based Yahoo and Japan's Softbank agreed to cap their shareholder voting rights in Alibaba at below 50 percent, said one source familiar with the issue, effectively keeping foreign ownership in check.

In addition to the share repurchase, Yahoo and Alibaba will amend their existing technology and intellectual property licensing agreement, with Alibaba continuing to operate Yahoo China under the Yahoo brand for up to four years. Yahoo will be freed from restrictions on it making other investments in China. Alibaba will make an upfront lump sum royalty payment of $550 million to Yahoo and keep paying royalties for up to four years.

UBS was lead financial adviser to Yahoo, while Credit Suisse advised Alibaba.