“To falsely accuse anyone of a drug sale is not only unacceptable; it is a crime,” Mr. Vance added.

Officer Alicea, who turns 29 on Thursday, pleaded not guilty and was released without bail. His lawyer, Angelo G. MacDonald, said outside the court that Officer Alicea maintained he had made a good arrest.

“They say there was no drug sale; my client says there was,” Mr. MacDonald said.

Mr. Alicea joined the Police Department in 2006 and had an unblemished work record, Mr. MacDonald said. He had been assigned to patrol housing projects in Upper Manhattan, where he was known by colleagues for making a lot of arrests.

The Police Department’s Internal Affairs Bureau has been investigating the arrests since last year, Mr. MacDonald said. He added that Officer Alicea was reassigned about six months ago to work in courthouses in Brooklyn. The officer also, according to the indictment, unlawfully searched one of the men’s mailboxes at the housing project. Mr. MacDonald declined to say whether his client had any previous disputes with the two men.

Officer Alicea was suspended on Wednesday, the police said.

“Unfortunately, sometimes, officers think that they are advancing the prospects for a successful prosecution by providing information that is not entirely true,” said Paul J. Browne, the Police Department’s chief spokesman. “It’s not for personal gain,” he said, but was “career-ending, nonetheless.”