Jose Pimentel appeared in a Manhattan courtroom on Wednesday. The Daily News/Associated Press

A Manhattan man will serve 16 years in prison as part of a plea agreement reached Wednesday in a rare terrorism case brought by state prosecutors.

Jose Pimentel, 29 years old, was accused of making one pipe bomb and planning to create more for use on soldiers returning from wars in Iraq and Afghanistan. Other targets included the New York Police Department, Jews and "in general a civilian population whom he described often as collateral damage," said prosecutor Deborah Hickey.

The plea, Manhattan District Attorney Cyrus Vance Jr. said, shows that terrorism threats increasingly come from "radicalized local actors living in our communities."Mr. Pimentel faced a potential life sentence if convicted at a trial that was set to start next week.

In November 2011, Mr. Pimentel—a Dominican Republic native and U.S. citizen living in his mother's Washington Heights apartment—was arrested by NYPD detectives following a 2½-year investigation.

The Joint Terrorism Task Force—led by the Federal Bureau of Investigation—was conducting its own investigation into Mr. Pimentel using some of the same informants.

But the FBI opted not to pursue the case because officials were concerned with the reliability of the informants and were skeptical that Mr. Pimentel could have pulled off a terrorism attack on his own.

Mr. Vance said the distinction between whether the federal or state government pursued the case is "overstated," adding, "if a bomb were to go off no one cares which law enforcement agency was involved or when." Mr. Pimentel's case is one of only three prosecutions under a state antiterrorism law passed in the weeks following the Sept. 11, 2001, attacks.

The deal calls for 16 years in prison followed by five years of supervised release. Mr. Pimentel will be formally sentenced for attempted criminal possession of a weapon as a crime of terrorism by Manhattan Supreme Court Justice Thomas Farber on March 25. He has already served two years.

Sixteen years is a year more than the minimum sentence he faced on his initial top terrorism charge, criminal possession of a weapon as a crime of terrorism, Mr. Vance said.

Mr. Pimentel wrote a statement to the court that Justice Farber read into the record Wednesday.

"I engaged in conversations about committing acts of violence related to the foreign policy of the U.S." and undertook those actions to "undermine support for the wars in Iraq and Afghanistan," he wrote.

After the hearing, Mr. Pimentel's lawyers, Susan Walsh and Lori Cohen, said it was their client's decision to accept the plea; he didn't want to take the chance of a potential life sentence.

The lawyers had planned to present an entrapment defense, they said, claiming that one informant provided the unemployed Mr. Pimentel with marijuana, food, money, a place to access the Internet and occasionally shelter over two years.

The crimes allegedly took place in the apartment of the informant.

"We always wish that we in all our cases might have priests or rabbis as our key witnesses but this is life and we have to take our witnesses where we find them," Mr. Vance said.

Their defense would also claim that Mr. Pimentel neither had the wherewithal nor mental capacity to accomplish the terrorism attack as charged.