It was a tip that likely saved hundreds of lives.

In 1997, an Egyptian university graduate who came to the US through the diversity visa program — which President Trump has called for ending after Tuesday’s carnage in lower Manhattan — helped thwart two would-be suicide bombers aiming to attack a Brooklyn transit hub.

Abdel Rahman Mosabbah was living in a squalid Park Slope apartment with several other Arab immigrants when one of his roommates, a Palestinian named Gazi Abu Mezer, showed him a pair of pipe bombs he’d made, the Daily Beast reported.

It was July 30, 1997, the same day two suicide bombers killed 16 people at a market in Jerusalem.

“Did you see what happened in Jerusalem?” Abu Mezer asked Mosabbah, according to the Daily Beast. “Well, tomorrow it will happen here.”

Abu Mezer said he and another Palestinian roommate, Lafi Khalil, intended to set off the pipe bombs at the Atlantic Avenue station the next morning in hopes of killing Orthodox and Hasidic Jews heading to work in the Midtown Diamond District.

Mosabbah, who’d been living in America for only a few weeks, left the apartment in horror, unsure whom he should tell about the disturbing revelation.

He spotted two Long Island Rail Road cops around 11 p.m. outside the Atlantic Avenue station and attempted to explain what his roommate had told him, repeating the word “bomba.”

They took him to the 88th Precinct house, but hours passed before they were able to get an FBI translator to come over.

Despite doubts about Mosabbah’s story, members of the Emergency Service Unit raided his apartment shortly before 5 a.m.

A struggle ensued, and both Abu Mezer and Khalil were shot by police, but ultimately survived.

Inside the apartment, police found the deadly devices.

“The information received, some people attribute to good luck and good fortune,” Mayor Rudolph Giuliani said later.

“Some people attribute it to an act of God, or maybe to an act of a conscience that ultimately unites all men and women when they realized that beyond racial, religious, ethnic, and even political differences, we are all united as people and human beings and that we have to protect each other and help each other.”

Trump called for Congress to end the diversity visa lottery after it emerged that Big Apple terror suspect Sayfullo Saipov, who allegedly killed eight people Tuesday, entered the US in 2010 after winning one of the visas.

The visas are awarded to citizens from countries that have a small number of immigrants in the US.