No user information was compromised in the attack, according to the tech giant, which said it had fallen victim to the same hackers that targeted Facebook last month.
Hackers found a vulnerability in an Internet browser plug-in developed for Oracle's Java program. Apple said it will release a software patch to prevent the problem from spreading.
"The malware was employed in an attack against Apple and other companies, and was spread through a website for software developers," according to company statement. "We identified a small number of systems within Apple that were infected and isolated them from our network. . . . We are working closely with law enforcement to find the source of the malware."
The company did not specify how many computers were affected, when the attack occurred or what kind of information the hackers were seeking.
Apple has not shipped computers with Java installed since the introduction of OS X Lion (version 10.6), and the company's computers automatically disable Java in browsers if it has not been used in more than 35 days.
The hackers who attacked Apple were linked to the same Chinese-based group that infiltrated Facebook's network in January, according to Reuters. High-profile cyber attacks said to be connected to Chinese hackers have also hit news organizations, including The Washington Post and the New York Times.
Cybersecurity has emerged as a top priority for the Obama administration, which has directed the Commerce Department to work with companies in vital industries to craft rules for sharing cyber-threat information with the government.
The Washington Post Co.'s chairman and chief executive, Donald E. Graham, is a member of Facebook's board of directors.