Yahoo and Alibaba have finally agreed to a deal that will see the Internet pioneer sell back half its stake in China e-commerce giant for $7 billion, the companies announced this evening.

The taxable deal, which was first reported by All Things D, includes a complex share buyback plan by Yahoo and an Alibaba IPO.

"Today's agreement provides clarity for our shareholders on a substantial component of Yahoo!'s value and reaffirms the significance of our relationship with Alibaba," said Ross Levinsohn, interim CEO of Yahoo, in a statement. "We look forward to continued collaboration with the Alibaba team on business initiatives as we explore joint opportunities for growth and benefit from Alibaba's future."

Yahoo is expected to sell half its 40 percent stake in Alibaba, roughly 20 percent of the company, in a deal that values the company at $35 billion. Yahoo is then expected to take its considerable capital gains from that sale and start buying back its own shares, which have long languished in the mid-teens.

Incentives would also be put in place for an Alibaba IPO at some time in the future, at which time Yahoo would sell its remaining quarter of the company. At the time of the IPO, Alibaba will be required to either purchase half of Yahoo's remaining stake or allow Yahoo to sell its shares in the IPO. Yahoo will then have the option to sell its remaining stake at any time after Alibaba's public offering.

The deal finally puts an end to one of more difficult corporate relationships in the Internet community. Yahoo, which has been in a state of uncertainty for months, was said to be considering a deal to sell its Asian assets back to their majority holders in a tax-free deal worth $17 billion. However, an ownership swap involving Alibaba and Yahoo Japan fell apart earlier this year.