The counterclaim from Facebook, filed in a San Francisco federal court, comes after Yahoo a sued Facebook for patent infringement last month.
The dueling claims mark an expanding web of patent litigation that has already caught up thesmartphone and tablet sectors and high-tech stalwarts such as Apple Inc, Microsoft Corp andMotorola Mobility Holdings Inc.
Yahoo's lawsuit against Facebook came at a delicate time, as the world's largest Internet social networking service is preparing for an initial public offering that could value the company at up to $100 billion.
Observers have said that companies are usually more vulnerable to patent suits when they are in the IPO process, as investors scrutinize the risks involved in the business.
But Facebook's counterclaim comes as Yahoo addresses its own challenges: the Web pioneer has seen declining revenue, and newly installed Chief Executive Scott Thompson is facing a contentious proxy fight with activist hedge fund Third Point.
Yahoo spokesman Eric Berman said Facebook's counterclaim is "nothing more than a cynical attempt to distract from the weakness of its defense."
Five of the patents asserted by Facebook target features related to Yahoo's online advertising business, which Facebook pegged at 80 percent of Yahoo's 2011 revenue, according to the counterclaim.
Yahoo's Flickr photo sharing service infringed various Facebook patents involving the ability to connect with other users on the online service, to identify people in a photo and to generate personalized news feeds, according to the filing.
At least one of the patents asserted by Facebook -- a method for tagging digital media -- lists its chief executive, Mark Zuckerberg, as one of the inventors, according to a U.S. government database.
Facebook General Counsel Ted Ullyot said the company had indicated that it would defend itself vigorously in the face of Yahoo's lawsuit.
"While we are asserting patent claims of our own, we do so in response to Yahoo's short-sighted decision to attack one of its partners and prioritize litigation over innovation," Ullyot said in a statement.
Yahoo has claimed Facebook infringed 10 of Yahoo's patents, including several that cover online advertising technology. In its lawsuit, Yahoo said Facebook was considered "one of the worst performing sites for advertising" prior to adapting Yahoo's ideas.
The case in U.S. District Court, Northern District of California is Yahoo Inc. v. Facebook Inc., 12-cv-1212.
Yahoo shares fell 2.4 percent to $15.09 in afternoon trading on Tuesday.