The scenes from Ferguson, Missouri, Wednesday night appeared to be right out of Iraq or Afghanistan, with heavily armed men on military vehicles and armored personnel carriers peering through night-vision goggles into a smoke-filled landscape. At least one officer knelt behind a tripod-mounted rifle, apparently at the ready to open fire if ordered to do so.

The resemblance between the near and the far was no accident, as some of the military gear and weaponry in the hands of Ferguson police likely came from the Pentagon, as did much of the materiel being used in those faraway military conflicts.

Local law enforcement agencies around the U.S. are eligible to receive surplus military equipment through the Defense Department’s 1033 program, whose motto is "from warfighter to crimefighter." They also can purchase similar equipment through grants from the Department of Homeland Security.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The 1033 program has transferred more than $4.3 billion worth of military equipment to law enforcement since its inception in 1997 – including more than $449 million in 2013 alone, according to the Defense Logistics Agency's Law Enforcement Support Office, which administers the program.

Foreign militaries also receive surplus gear and weaponry from the Pentagon, but a review of the Defense Security Assistance Agency's databases show that only Israel, which requested $328 million in excess defense articles this year, comes close to receiving as much. Morocco, with $90 million of surplus military equipment, is next on the list.

The excess materiel requested by U.S. allies is very often similar to that requested by local police, including equipment like HumVees, armored personnel carriers, rifles and machine guns. (Separately, Afghanistan's national police force, which is fighting the Taliban, received $241 million in new U.S. weaponry and transportation equipment.)

Even compared to the Foreign Military Financing program, which sends U.S. military aid overseas, including big weapons systems, Pentagon aid to law enforcement would rank fourth overall, according to Bill Hartung of the Center for International Policy. For fiscal 2014, it would trail only Israel ($3.1 billion), Egypt ($1.3 billion) and Iraq ($850 million), and rank ahead of such U.S. allies as Jordan ($300 million), Lebanon ($75 million) and Colombia ($40 million), he noted.

Follow NBC News Investigations on Twitter and Facebook.

It’s not clear how much – if any -- of the military equipment seen in Ferguson on Wednesday during protests over the shooting death of 18-year-old Michael Brown by an unidentified police officer came through the 1033 program.

USA Today and Newsweek reported Thursday that St. Louis County law enforcement agencies received two military vehicles as well as a trailer and a generator in November 2013 and 12 5.56 millimeter rifles and six .45 caliber pistols between Aug. 2, 2010, and Feb. 13, 2013. But the Pentagon only reports data on the county level, making it impossible to say whether any made its way to Ferguson police.

NBC News could not immediately confirm the figures.