The National Security Agency has implanted software that can communicate through radio waves with almost 100,000 computers around the world, allowing it to spy on users and carry out cyber-attacks even if the computers are not connected to the Internet, a report claimed Tuesday night.

The NSA secretly bugged the computers with the help of spies, the units’ manufacturers — and even the unwitting users themselves, according to The New York Times.

The program — code-named Quantum — has been in place since 2008 and has targeted foreign-government agencies such as the Chinese and Russian militaries.

It has not, however, been employed domestically in the United States, the Times said.

The US government has insisted that the program is intended only for defense purposes and to prevent ­cyber attacks.

The sophisticated spy program uses radio frequencies to access computers that are inaccessible through the Internet, the ­report said.

In some cases, the hardware used to detect the radio frequencies are physically inserted into the foreign computer by a spy.

Sometimes, the agency sets up a relay station the size of a briefcase miles from the device in which the software is implanted. The radio waves can then be beamed straight from the remote station to the computer.

The Chinese military, which has been accused of a hacking American computers, is said to be ­using similar technology.

Other targets of the US program have been Mexican drug cartels, European Union institutions and the governments of Saudi Arabia, India and Pakistan, the report said.

An NSA spokeswoman said the programs are used for valid purposes and are not intended to poach ­financial information.

“NSA’s activities are focused and specifically deployed against — and only against — valid foreign intelligence targets in response to intelligence requirements,” Vanee Vines told the newspaper.

“We do not use foreign-intelligence capabilities to steal the trade secrets of foreign companies on behalf of — or give intelligence we collect to — US companies to enhance their international competitiveness or increase their bottom line.”

A detailed map published on the Dutch Web site NRC.nl displays various oversees targets.

The site said that the malware implanted into the target computers can be remain active for years without being detected, and can be turned off at will.

Some information about the program had earlier been included in documents released by notorious NSA leaker Edward Snowden.

In addition, the German publication Der Spiegel detailed the various methods used by the NSA to circumvent firewalls and access protected networks.

But the new revelations give more ammunition to critics of the massive data-collection agency, and increases pressure on President Obama, who is set to enact recommendations made by an advisory panel on changes in surveillance.