SAN FRANCISCO — Yahoo CEO Marissa Mayer is spinning off the company’s prized stake in China’s Alibaba Group Holding in a move that will enable Yahoo to avoid paying billions of dollars in future taxes.

A newly formed entity called SpinCo will inherit ownership of Yahoo’s 384 million Alibaba shares when the tax-free spin-off is completed toward the end of this year.

Yahoo’s own stock gained $3.51, or more than 7 percent, to $51.50 in extended trading after Mayer disclosed her plans for Yahoo’s 15 percent stake in Alibaba.

Tuesday’s much-anticipated announcement overshadowed Yahoo’s results for the final three months of last year.

Yahoo Inc. invested just $1 billion in Alibaba nearly a decade ago, a bargain that subjected the company to massive tax bills as it has whittled its stake during the past three years.

The Alibaba stake is currently worth $39 billion, intensifying the shareholder pressure on Mayer to come up with a plan to minimize future taxes. The Alibaba investment is also worth far more than Yahoo’s. Yahoo has been struggling to generate more revenue for the past six years while rivals Google Inc. and Facebook Inc. grabbed a bigger piece of digital marketing budgets.

Alibaba had its initial public offering of stock in September. The Chinese company is attractive to investors in part because most of its users visit on smartphones and other mobile devices at least once a month – important as computing shifts away from traditional laptops and desktops.

Investments in Alibaba, China’s largest e-commerce company, and Yahoo Japan are the main reason Yahoo’s stock has more than tripled since Mayer defected from Google to become Yahoo’s CEO two-and-half years ago. Yahoo is retaining its nearly 36 percent stake in Yahoo Japan, worth nearly $7 billion, BGC Financial analyst Colin Gillis estimated.

“This is ideal for shareholders and shows that (Mayer) is aligning herself with shareholder interests, at least for now,” Gillis said.

The handling of Yahoo’s Alibaba stake is so important to shareholders that one activist investor, hedge fudge manager Jeffrey Smith of Starboard Value, has threatened to spearhead an attempt to oust Mayer if she didn’t adopt a strategy that minimizes taxes. Smith also has been pressuring Mayer to commit to returning most of any future Alibaba windfalls to shareholders instead of spending the money to buy other companies – unless she embraces his call for Yahoo to merge with rival AOL Inc.

A tax-free spin-off of the Alibaba stake ranked high on Smith’s agenda.

Starboard Value did not immediately respond to a request for comment.