It looks like Facebook has finally gotten fed up with all the viruses and spam that is plaguing the social network and ensnaring and embarrassing its 350 million members.

Late Tuesday, the company announced a deal with McAfee, a leading maker of antivirus software, to give Facebook users a complimentary six-month subscription to McAfee’s Internet Security Suite. After that, Facebook users will be entitled to discounts on the software. Under the terms of the partnership, McAfee will become Facebook’s exclusive provider of consumer security software for one year.

Facebook will also begin using a McAfee tool to scan the computer of any user whose account gets compromised by malware. (There have been some high-profile examples recently.) Facebook users whose accounts get hijacked have to go through a remediation process. As part of that, they will now have to subject their computers to this scan to regain control over their Facebook account.

“We have seen an absolute huge rise in malware worldwide over the past 12 months, probably more than the previous five years combined,” said David DeWalt, McAfee’s chief executive. “We are seeing a lot more malware specifically designed and targeted at large social networking applications. These are just the trends in the industry.”

Mr. DeWalt said more than half of all Internet users still had no anti-virus software protecting their computers.

Elliot Schrage, Facebook’s vice president of communications and public policy, said that Facebook has its own technology that aims to keep malware off the site. But, he said, “as security continues to be an issue for Facebook and across the Web, we realized that if we really wanted to build a leadership position that defines best practices for helping users have a safe experience, we needed to partner with other industry leaders.”