A top NYPD official on Friday issued a stunning apology to the Prospect Park rape victim he helped discredit more than 23 years ago — as the victim spoke out for the first time since her case was finally solved.

“As a police official—even one who’s job was to deal with the press—I had a higher obligation to the citizens we serve, especially the witnesses to and victims of crime,” said John Miller, a former NYPD spokesperson who is currently the deputy commissioner for counterterrorism and intelligence, in an email obtained by The Post.

“While I learned that lesson 24 years ago, I most regret that it was at the expense of one of those who had the courage to come forward.”

Miller, then an NYPD spokesperson, told reporters in 1994 that police had doubts about the woman’s account, saying there was a lack of physical evidence and there appeared to be inconsistencies in her story.

He also acted as a source for Daily News columnist Mike McAlary, who wrote in a piece that said police believe the attack was a “hoax.”

“Inappropriately sharing this information, which was the speculation of investigators, and ultimately proved to be incorrect, was a serious misjudgment on my part,” Miller said in his apology statement.

“It re-victimized a person who was already the victim of a terrible crime. I sincerely apologize to her for that.”

A lawyer for the woman said Friday night that Miller’s apology is not accepted.

“Miller and the police did not make a bookkeeping mistake. He, because of racism and sexism, called an honest woman a liar and hoaxer,” said her attorney Martin Garbus.

“The police lied and lied, first about Jane Doe and then to help their friend Mike McAlary enhance his reputation and defend his perjurious libel cases.”

The victim, a 27-year-old Yale graduate, was raped in Prospect Park while walking home with groceries.

Her case was recently solved after more than 23 years, when DNA evidence linked the crime to serial rapist James Edward Webb, 68, who is serving 75 years to life at Sing Sing.

Here is the victim’s statement in its entirety: