Three Brooklyn men used blow torches, hammers and cutting tools to burglarize two banks and loot them of $5 million in cash, jewelry and other valuables in what may be one of the biggest such heists in New York City in years, authorities said Tuesday.

Federal agents and NYPD detectives Tuesday morning arrested Michael Mazzara, 44, Charles Kerrigan, 40, and Anthony Mascuzzio, 36, on charges related to break-ins at an HSBC branch at 4406 13th Ave. in Brooklyn in April and at a Maspeth Federal Savings Bank branch at 64-19 Woodhaven Blvd. in Queens in May.

All three were charged with conspiracy and involvement in the burglary of the Maspeth Federal Savings branch, while Kerrigan and Mazzara also were charged with the break-in at HSBC, according to a federal criminal complaint unsealed in the case. Court appearances for the trio were pending late Tuesday.

The complaint charged that the defendants worked in the dark of night and on weekends to break through the roofs and into the vaults of the two banks and ransacked scores of safe deposit boxes, taking cash, precious stones and irreplaceable mementos, officials said.

In the Maspeth Federal case, the suspects used a plywood structure painted black on the roof of the bank to hide themselves as they used a blow torch to get into the vault.

“The thieves stole not just people’s money but their memories too,” Manhattan U.S. Attorney Preet Bharara said at a news conference. “What was left at the banks and the roofs of the banks looks like something out of scenes from a movie.”

NYPD Commissioner William Bratton said the heists reminded him of the plot in the 1995 film “Heat” starring Robert DeNiro and Al Pacino in which a group of thieves, led by DeNiro, rob an armored car and are hunted down by detectives led by Pacino.

While the two burglaries were bold, Bharara lauded “really incredible” police work by the FBI and NYPD organized crime task force, which broke the case quickly by going through mountains of credit card receipts, cellphone records and other documents.

“They analyzed surveillance videos from around HSBC bank and were able to identify the cars used by crews,” said Bharara, adding detectives found receipts for plywood purchased by the suspects.

Mazzara and Mascuzzio have checkered backgrounds, officials said. In August 2009, Mazzara, then 37, was critically wounded during an argument over a Jet Ski at a marina in Sheepshead Bay, said Chief of Detectives Robert Boyce. Mascuzzio is the son of the late Gambino crime family associate Anthony Mascuzzio, who was shot dead at a Manhattan disco in June 1988 at age 43, investigators said. The younger Mascuzzio was released from federal prison last year after his federal conviction for trafficking marijuana, prison records show.

Bharara said that search warrants were issued for seven locations and detectives were trying to see if any of the stolen items have found so they can be matched to victims.