Apple is releasing a malware removal tool after a number of Mac systems were infected by computer hackers.
The admission by Apple of a widespread cyber-security breach comes the week after Facebook revealed it had been the victim of a similar attack.
Unknown hackers infected the computers of some Apple workers when they visited a website for software developers that had been infected with malicious software. The malware had been designed to attack Mac computers.
The same software, which infected Macs by exploiting a flaw in a version of Oracle Corp's Java software used as a plug-in on Web browsers, was used to launch the attacks against Facebook
A site devoted to sharing information called iPhoneDevSDK has been named by website AllThingsD as a possible source of the hacks on both Apple and Facebook.
Apple said there was no indication that any data had been taken and it was working with authorities in the US to investigate the incident.
The California-based makers of the iPhone and iPad said in a statement: "Apple has identified malware which infected a limited number of Mac systems through a vulnerability in the Java plug-in for browsers.
"The malware was employed in an attack against Apple and other companies, and was spread through a website for software developers. We identified a small number of systems within Apple that were infected and isolated them from our network.
"There is no evidence that any data left Apple."
It added that it was releasing an updated Java malware removal tool that would remove the malware from computers if found.
Last week Facebook said on its security blog the company discovered that its system had been targeted in a sophisticated attack in January.
The attack occurred when a handful of the company's employees visited a developer's compromised website, which led to malware being installed on their laptops.
Facebook also said it has found no evidence that user data was compromised.
Twitter , which disclosed that it had been breached earlier this month and that hackers might gave accessed some information on about 250,000 users, was hit in the same campaign, according to a person close to the investigation.