AMMAN, Jordan — Two American contractors and a South African colleague were gunned down Monday at a U.S.-funded police training center in Jordan, officials said.

Jordan's embassy in Washington said two Jordanians also died in the attack at the facility in eastern Amman. The gunman — a Jordanian police officer — was killed at the scene, according to a statement from the embassy. It added that four others — including two Americans — were injured.

Government spokesman Mohammad Momani told NBC News that the attack unfolded in the cafeteria of the training facility and that an investigation was underway into the gunman's motives.

U.S. defense officials told NBC News that the attacker was a disgruntled former cop who'd recently been fired.

Forces guard the entrance of the facility where the shooting occurred on Monday. Jordan Pix via Getty Images

The U.S. Embassy in Jordan confirmed two "U.S. government employees" had died in the shooting at the Jordan International Police Training Center southeast of Amman.

"The investigation is ongoing and it is premature to speculate on motive at this point," it said in a statement. "We are working closely with the government of Jordan and local security services on a full and comprehensive investigation."

It urged American citizens to avoid the area around the facility, which was established as a center to train Iraqi police and since has offered training to other nations.

The Americans killed were contractors from Dyncorp working on a program designed to train Palestinian Security Forces, according to the State Department.

Jordan — a key U.S. ally — is participating in the American-led coalition fighting to defeat ISIS. The kingdom has deployed troops, launched airstrikes on ISIS targets and also hosts F-16 fighter jets in the area to strike the terror group.

Monday's attack coincided with the 10th anniversary of suicide bombings targeting luxury hotels in Jordan's capital.