Barnes & Noble shares closed down 5.4 percent on the New York Stock Exchange after the company also reported a much-weaker-than-expected quarterly profit, due to lower sales of Nook devices.
               
The company estimated the value of the cash and share deal at about $125 million.
               
Nook, launched in 2009, enjoyed initial success but has ended up costing Barnes & Noble; Noble hundreds of millions of dollars as it was unable to keep pace with Amazon.com Inc's  Kindle and Apple Inc's iPad.
               
Microsoft invested $300 million in Barnes & Noble's Nook e-reader in 2012 to gain a foothold in the fast-growing e-books market. As of Sept. 9, Microsoft owned about 17 percent of Nook Media through preferred shares.
               
Barnes & Noble said in June it would spin off its Nook Media business, which includes college bookstores, to focus on its  retail book business.
               
"We mutually agreed that it made sense to terminate the agreement," a Microsoft spokesman said in an email. Microsoft will lose money on its initial investment, but will also be spared any future payments to fund Nook, which were running at about $21 million per quarter.
               
Under the agreement announced on Thursday, Microsoft will have the right to receive about 22.7 percent of total proceeds of Nook's digital business, which excludes the college bookstores, if it is sold in the next three years.
               
Pearson Plc owns 5 percent of Nook Media, which had revenue of $815 million in the second quarter ended Nov. 1.
               
The company said it would buy Microsoft's stake in Nook Media for $62.4 million in cash and about 2.7 million in shares.
               
Barnes & Noble said it now expected to complete the separation of its Nook Media business at the end of August 2015. It had earlier expected to complete it by March.
               
The company said its total revenue fell 2.6 percent to $1.69 billion in the second quarter. Retail sales fell 3.6 percent.