Michael Appleton for The New York Times

The authorities have arrested a man who law enforcement officials believe was planning to build and detonate a bomb in New York with government workers, returning military personnel and elected officials as the target, two people briefed on the case said on Sunday.

Cyrus R. Vance Jr., the Manhattan district attorney, Mayor Michael R. Bloomberg and Commissioner Raymond W. Kelly of the New York Police Department announced the charges against the man at a Sunday evening news conference at City Hall.

The man was arrested within the last 24 hours.

The defendant in the case, identified as Jose Pimentel, 27, had bought bomb-making materials and “began to build them,” said one person briefed on the case, who added that the Police Department had had the man under surveillance for about a year.

“The Police Department basically had an informant with this guy,” said a second law enforcement official familiar with the investigation. “The guy is sort of giving to the informant all of these material on bomb building and talking about building a bomb and supporting the mujahedeen by targeting — he’s kind of all over the place; sometimes it’s targeting servicemen and women returning from Afghanistan, sometimes it’s the police, sometimes its build it and test it, but it’s all over the place.”

Andrew Burton/Reuters

“He was in the process of building three pipe bombs,” the law enforcement official said. “We weren’t going to wait around to figure out what he wanted do with his bombs. He was in Harlem about an hour from actually assembling the bombs,” but had all the “unassembled components ready to go.”

Holes were drilled into pipes; sulfur was scraped off of matches; nails were ready to be used as shrapnel; and some sort of wires were used to fashion an ignition device, the official said.

The person briefed on the case described it as a “lone-wolf scenario” and said that Mr. Pimentel had been considering a possible array of targets that included government employees, lawmakers and military personnel returning from overseas service.

Mr. Pimentel, who is also known as Muhammad Yusuf, will face charges that include criminal possession of a weapon in the first degree as a crime of terrorism, which is considered an A-1 violent felony.

Mr. Pimentel made incriminating statements to an informant who was working with the Police Department, investigators said, and those conversations were recorded.

Investigators also said he bought materials to make a bomb at a 99 cent store and at a Home Depot on Exterior Street in the Bronx. At the Home Depot, he bought elbow joints, gloves and Christmas lights. He was under surveillance by the Police Department when he made those purchases.