After he was arrested while sitting in a running car with a blood-alcohol level above the legal limit, a Navy man offered a story that a jury could believe, and had a friend to back it up.

Petty Officer First Class Leonel Polanco-Colon told a Manhattan jury last year that he was in the car that night only to charge his phone, and that he had a friend inside who was the designated driver.

The friend, Luis D. Nunez, told the same story to the jury, and Petty Officer Polanco-Colon was found not guilty of driving while intoxicated, a misdemeanor, since the law required prosecutors to prove the sailor had at least intended to drive the car.

But on Monday, the two men were charged with a more serious crime — perjury, a felony. Prosecutors said that Mr. Nunez was not even with Petty Officer Polanco-Colon that night, and that they had invented the designated-driver defense.

Petty Officer Polanco-Colon’s lawyer in the new case, Timothy Parlatore, said his client had followed bad legal advice during the drunken-driving trial.

“This is a situation where my client got terrible, terrible advice and followed it,” Mr. Parlatore said outside court. “But he is doing everything he can now to rectify that situation.”

The indictment identifies the lawyer in the drunken-driving case only as “Attorney Doe,” but puts him in the center of plans to coordinate false testimony.

After Petty Officer Polanco-Colon’s testimony varied from the plan, the indictment says, he met with Mr. Nunez and the lawyer that night “to ensure that Mr. Nunez would alter his anticipated testimony” to match what the defendant had told the jury.

The lawyer has not been charged, though criminal charges or professional disciplinary charges are possible, given the nature of the case.

Petty Officer Polanco-Colon, 32, appeared briefly at State Supreme Court in Manhattan wearing a dark suit. He pleaded not guilty to eight counts of perjury, a felony that carries a maximum sentence of up to seven years in prison, and was released without bail.

“Honest testimony is the bedrock of our legal system,” Cyrus R. Vance Jr., the Manhattan district attorney, said in a statement. “The cover-up is, in this case, more serious than the crime.”

Petty Officer Polanco-Colon’s acquittal on the drunken-driving charge means that he cannot be retried on that offense, which carried a maximum of a year in jail.

The testimony from the trial quoted in the indictment describes a tightly woven account of an imaginary night out together.

Both men testified that about 11 p.m. on Aug. 16, 2011, Petty Officer Polanco-Colon picked up Mr. Nunez at his home in the Bronx. They drove to Cafe Tabaco y Ron, a restaurant in the Inwood section of Manhattan, and shared a pitcher of sangria, Buffalo wings and calamari, they testified.

“We have some food, we had few drinks, and we, actually, conversating, just socializing with people,” Petty Officer Polanco-Colon testified.

They said they got back in the car at 1 a.m. and drove to the Gaslight Lounge, in the fashionable meatpacking district. Mr. Nunez seemed to have a clear memory of the trip downtown, considering prosecutors say it never took place.

“So, it took you 20 minutes to get from Tabaco y Ron to the Gaslight?” a lawyer asked Mr. Nunez during the trial.

“Yes,” he answered. “Traffic was light. We went down the West Side Highway. We got there quick.”

Petty Officer Polanco-Colon said he gave his friend the keys when they arrived. Mr. Nunez said he had drunk only bottled water and was surprised when his friend vanished. “I was very worried because that’s unlike of him to do something like that,” Mr. Nunez said during the trial.

Mr. Nunez, 29, is accused of another act of deception.

Last month, he was spotted showing a fake police badge to a subway attendant in the Bronx to gain free access to the subway, according to people briefed on the case. Mr. Nunez tried to convince an investigator who approached him that he was a police officer, and then sprayed the investigator with pepper spray to try to escape, the authorities said.

A prosecutor said Mr. Nunez, who faces charges of impersonating a police officer and assault in that case, was too sick on Monday to leave Rikers Island and be arraigned on six perjury counts related to his testimony at Petty Officer Polanco-Colon’s trial.

A version of this article appears in print on , Section A, Page 18 of the New York edition with the headline: Story That Helped Win D.W.I. Trial Brings Perjury Charges. Order Reprints | Today’s Paper | Subscribe