After months of speculation, Yahoo has finally announced that it has agreed to a deal to sell a significant part of its 20 percent stake in Alibaba back to the Chinese ecommerce giant. The agreement also frees the US firm to invest in other ventures in China, should it wish to.

The deal is worth $7.1 billion, composed mostly of stock, and will take place in phased stages over the coming period. The official announcement reveals the removal of restrictions on Yahoo making “other investments” in the country, while clarifying that Alibaba will retain the Yahoo China license:

Among other things, this amendment will result in Yahoo! granting Alibaba a transitional license to continue to operate Yahoo! China under the Yahoo! brand for up to four years, while restrictions on Yahoo!’s ability to make other investments in China will be terminated.

With Yahoo reportedly keen to also offload its stake in Yahoo Japan — its joint venture with operator Softbank — the prospect of further investment in Asia is unlikely and would appear to go against its restructuring.

However, China is attractive to many of overseas companies including Evernote, PayPal, Facebook and even Google, which maintains its presence there despite a high profile withdrawal, so the possibility can’t be entirely dismissed.

A possible Alibaba IPO is also cited within the agreement and such an event would see Yahoo’s ownership decrease further still:

At the time of an initial public offering (IPO) of Alibaba in the future, Alibaba will be required either to repurchase one-quarter of Yahoo!’s current stake at the IPO price or allow Yahoo! to sell those shares in the IPO. Second, following such an IPO, Yahoo! has registration rights and rights to marketing support from Alibaba to enable Yahoo! to dispose of its remaining shares, at times of Yahoo!’s choosing following a customary lock-up period.

Other clauses will see Alibaba make a significant upfront royalty payment of more than half a billion dollars:

Alibaba will make an upfront lump sum royalty payment of US$550 million to Yahoo! and continuing royalty payments for up to four years. In addition, Alibaba will license certain patents to Yahoo.

Yahoo is not leaving its stake involvement entirely and will continue to hold a board seat with voting rights at the Chinese firm.

The struggling US giant has enjoy better fortunes in Asia, although its recent culling of 2,000 jobs has affected its presence in the region it once dominated. Most notably, Yahoo laid off the entire product team behind Koprol — the Asian location-based service it bought in 2010leaving its future unclear.