ALEXANDRIA, Va. (AP) - A federal magistrate on Thursday ordered an ex-Marine reservist accused of firing shots at the Pentagon and other military targets to remain in jail while he awaits trial.

Prosecutors said at a detention hearing that Yonathan Melaku, 23, of Alexandria, Va., is both a danger to the community and a flight risk.

Assistant U.S. Attorney Neil Hammerstrom said the evidence is overwhelming linking Melaku to a series of overnight shootings in October and November 2010 at the Pentagon, two separate shootings at the National Museum of the Marine Corps in Quantico, a Marine Corps recruiting station in Chantilly and a Coast Guard recruiting office in Woodbridge.

Hammerstrom said ballistics evidence links all five shootings to the same gun, and authorities found a video that they say Melaku made of himself that shows him firing shots from Interstate 95 at the Marine Corps museum. A court affidavit quotes Melaku on the video saying, "That's what they get. That's my target. That's the military building. It's going to be attacked."

No one was injured in any of the shootings.

Melaku's attorney, Gregory English, argued unsuccessfully that Melaku - a naturalized U.S. citizen from Ethiopia - could be released to his father's custody with electronic monitoring.

Melaku was arrested and charged in June when he was spotted after dark in Arlington National Cemetery with a backpack containing 20 pounds of ammonium nitrate, a potential bomb-making material, and notations referring to jihad and Osama bin Laden. That arrest set off a massive security scare around the Pentagon.

After the shootings, Melaku was dismissed from the Marine Corps reserves because of unrelated larceny charges in Loudoun County. He struck a plea deal on the state charges that resulted in a six-month jail term, including time served.

English has said his client is a loyal American.

If convicted on all four federal counts - two counts of damaging federal property and two counts of using a firearm to commit a crime of violence - Melaku would face a mandatory minimum of 35 years and a maximum sentence of life.