An Ashburn man who federal prosecutors said plotted to “kill as many Americans as possible” by bombing Washington Metro stations was sentenced Monday to 23 years in prison.

Farooque Ahmed, 35, a naturalized U.S. citizen born in Pakistan, pleaded guilty to two terrorism-related charges in U.S. District Court in Alexandria. Federal authorities said Ahmed conspired with people he thought were al-Qaeda operatives to bomb Metrorail stations at Arlington Cemetery, Pentagon City, Crystal City and Court House. In reality, he was dealing with people working for the U.S. government.

“Ahmed admitted he was determined to kill as many Americans as possible,” said U.S. Attorney Neil H. MacBride. “It’s chilling that a man from Ashburn pleaded guilty to these terrorist acts.”

In the courtroom, where Ahmed’s wife sat near the back with family and friends, Judge Gerald Bruce Lee said: “The looming question is why?”

Ahmed, with a full salt-and-pepper beard and glasses and wearing a green prison jumpsuit, stood before the judge and tried to explain.

“I can not describe the words . . ., ” he said, his voice trailing off. “All I can say is I’m sorry. It was the wrong action.”

In the 45-minute hearing, Ahmed pleaded guilty to attempting to provide material support to a designated foreign terrorist organization and collecting information to assist in planning a terrorist attack on a transit facility.

The judge called the charges “grave,” and said he considered the plans a “real threat to working people who use Metro every day.” Lee also gave Ahmed 50 years of supervised release.

According to court documents, Ahmed “surveilled, photographed, videotaped, diagramed” and helped gather information to plan “multiple bombings to cause mass casualties” at Metrorail stations.

Ahmed met at Northern Virginia hotels with individuals posing as al-Qaeda members. He delivered computer flash drives of his Metro station surveillance, provided details of the entrances and layouts, made written diagrams, and gave suggestions on where to place explosives at each location to kill the most people.

The best time to stage an attack and cause the most casualties, Ahmed said, would be between 4 and 5 p.m., according to court documents. He said he wanted to “kill as many military personnel as possible,” and suggested an attack on the Crystal City Metro stop, which is heavily used by those in the military.

Ahmed, who was arrested in October in a sting operation, also talked about participating in jihad by traveling overseas to fight coalition forces in Afghanistan, court papers say.

Kenneth Troccoli and Todd Richman, assistant federal public defenders, described their client’s life. Ahmed was a teenager when he came to the United States with his family. His father, a banker, had been transferred to the New York area.

Ahmed studied computer science, received a degree from the College of Staten Island in New York and later moved to Virginia, where was employed in various computer networking jobs.

As the economy soured, Ahmed — who worked as a contractor — had periods of unemployment, Troccoli said. It was during those times that Ahmed first became involved in planning terrorist attacks.

Troccoli said Ahmed had experienced racial and religious discrimination, which created “resentment that was a contributing factor” to his involvement in the plot.

Ahmed’s lawyers said he lived in a “fantasy world of secret codes” and “clandestine meetings.” Ahmed agreed to do surveillance of Metro stops, thinking the task had been assigned to him by al-Qaeda, his lawyers said.

Since his arrest, Troccoli said, Ahmed has “woken up” and believes that his actions were contrary to his Muslim religion.

Lee told Ahmed that even though he might have suffered discrimination, so have other minorities. But, he said, “the way to manifest it is not to plot to kill people.”