Taiwan is trying to figure out how hackers managed to trick a network of bank ATMs into spitting out millions.

Police said several people wearing masks attacked dozens of ATMs operated by Taiwan's First Bank on Sunday. They spent a few minutes at each of the machines before making off with the equivalent of $2 million stashed in a backpack.

They didn't use bank cards but rather appeared to gain control of the machines with a "connected device," possibly a smartphone, the police said in a statement Thursday. Authorities are now hunting the thieves, who they say came from Russia and eastern Europe.

The ATMs were made by German manufacturer Wincor Nixdorf (WNXDY). The company confirmed that several of its machines in Taiwan were hacked in a "premeditated attack."

Wincor Nixdorf said Thursday it had sent security experts to support local investigators in Taiwan.

Prosecutors said the machines were infected with three different malware files that instructed them to "spit out cash" and then deleted evidence of the crime. They described the case as the first of its kind in Taiwan.

Wincor Nixdorf said it has no evidence that the malware was introduced into the network via the ATMs themselves.

Related: Two hours and 1,600 fake credit cards later: $13 million is gone

First Bank and other Taiwanese banks have suspended some of their ATMs after the heist. The prosecutors' office instructed them to check for malware in their systems.

Taiwan Cooperative Bank said it will suspend its bank system for four hours on Saturday morning.

-- Vivian Kam contributed reporting.