AMMAN, Jordan — Weapons shipped into Jordan by the Central Intelligence Agency and Saudi Arabia intended for Syrian rebels have been systematically stolen by Jordanian intelligence operatives and sold to arms merchants on the black market, according to American and Jordanian officials.

Some of the stolen weapons were used in a shooting in November that killed two Americans and three others at a police training facility in Amman, F.B.I. officials believe after months of investigating the attack, according to people familiar with the investigation.

The existence of the weapons theft, which ended only months ago after complaints by the American and Saudi governments, is being reported for the first time after a joint investigation by The New York Times and Al Jazeera. The theft, involving millions of dollars of weapons, highlights the messy, unplanned consequences of programs to arm and train rebels — the kind of program the C.I.A. and Pentagon have conducted for decades — even after the Obama administration had hoped to keep the training program in Jordan under tight control.

The Jordanian officers who were part of the scheme reaped a windfall from the weapons sales, using the money to buy expensive SUVs, iPhones and other luxury items, Jordanian officials said.