The deal includes "a patent portfolio cross-license" and will allow the two firms to "work together to bring consumers and advertisers premium media experiences promoted and distributed across both Yahoo! and Facebook," a statement by the companies said.
The deal comes after Yahoo! filed suit against Facebook in March, accusing the social networking giant of infringing on 10 patents.
Facebook responded by accusing Yahoo! of infringing on its patented technology in a broad array of products including online venues for news, games, cars, travel and photo-sharing service Flickr.
The fight between Yahoo! and Facebook heated up in April with the floundering Internet pioneer accusing the social network star of buying patents just to retaliate in court.
But in the peace accord, Yahoo! and Facebook said they would "work together to bring Yahoo!'s large media event coverage to Facebook users by collaborating on social integrations on the Yahoo! site."
"We are excited to develop a deeper partnership with Facebook," said Ross Levinsohn, interim chief executive of Yahoo!.
"We are looking forward to building on the success we have already seen to provide innovative new products and experiences for both consumers and sponsors."
Sheryl Sandberg, Facebook's chief operating officer, said the deal would "provide users with engaging social experiences while creating value for marketers."
The two firms already have a multiyear partnership allowing users to discover and connect news and information on Yahoo! sites and share them with their Facebook friends.
The new agreement deepens the ties between the struggling Internet pioneer and the fast-growing social network.
The statement said the firms "have agreed to work more closely and collaborate together on multiple tent-pole and anchor events annually over the next several years to provide unparalleled experiences for consumers and world-class sponsorship opportunities for advertisers."
Patent suits are a frequent occurrence among smartphone and tablet computer makers, and the world's best known brands are ensnared in a complex web of legal claims, but such suits are relatively rare among social media companies.
Yahoo! is undergoing yet another rebooting following the ousting of its chief executive after less than a year over a resume scandal.
Levinsohn took over as interim CEO as a search for a new chief was launched.
Various reports said Levinsohn was among the candidates being considered to the top job.
Another candidate believed to be under consideration, Jason Kilar of the television group Hulu, said in a statement he "has graciously declined to be considered."
Yahoo!'s share of overall US online ad revenue dropped from 15.7 percent in 2009 to just 9.5 percent last year, according to industry tracker eMarketer.
While the online advertising market is expected to grow 23.3 percent to $39.5 billion this year, Yahoo!'s share of revenues will fall further to 7.4 percent, eMarketer says.
Facebook meanwhile is seeking to reassure its investors after a flopped public offering that it can boost its advertising revenues.
What the stars mean:
★ Poor ★ ★ Promising ★★★ Good ★★★★ Very good ★★★★★ Exceptional