Facebook is paying Microsoft $550m (£341m) for some of the patents it recently bought from AOL.
Microsoft paid more than $1bn for most of AOL's patents, beating rivals reported to have included Facebook.
A Facebook lawyer described the deal as: "Another significant step in our ongoing process of building an intellectual property portfolio to protect Facebook's interests."
Facebook was sued by Yahoo for patent infringement earlier this year.
"Today's agreement with Facebook enables us to recoup over half of our costs while achieving our goals from the AOL auction," said Microsoft's general counsel Brad Smith.
Microsoft bought 925 patents and patent applications from AOL. It is now selling 650 of those patents to Facebook as well as licenses to the other 275.
There has been a series of recent patent deals betwee
Facebook is paying Microsoft $550m n technology companies as they try to defend themselves in lawsuits.
If a company successfully sues another it can demand a sales ban of its competitor's products, or force the loser to pay expensive licence fees.
Since the start of the year, Intel, Google and Facebook are among those to have bought significant numbers of patents from other tech companies.
Facebook bought a number of patents from IBM last month.