Alibaba has reached agreement with Yahoo to buy back about half the U.S. portal’s stake in China’s largest e-commerce provider, Bloomberg reported this evening. Alibaba will repurchase about a 20% stake percent stake in itself for an estimated $7.1 billion ahead of a potential initial public offering. Yahoo will receive at least $6.3 billion in cash and as much as $800 million in newly issued Alibaba preferred stock, the companies said in a statement. Their agreement, which boards of both companies approved, also requires that Alibaba either buy back a quarter of Yahoo’s current stake at the price of a future IPO or let Yahoo sell the shares in the IPO. Alibaba has endeavored to buy back the stock for months. Although the deal reduces Yahoo’s presence in China it may help the U.S. portal’s turnaround efforts. Yahoo said the company intends to return “substantially all” of proceeds of the transaction, after taxes, to shareholders. Yahoo also increased its share buyback authorization by $5 billion with the agreement, and Alibaba will make an initial upfront royalty payment of $550 million and continue royalty payments for up to four years. Alibaba will also be allowed to operate under the Yahoo brand in China for up to four years. Restrictions on Yahoo’s ability to make other investments in China also will be eliminated.