Adm. William Moran is shown at a ceremony commissioning a ship in Boston on Dec. 1, 2008. (Paul Connors/The Boston Herald/AP)

A four-star admiral due to take over as the Navy’s top officer on Aug. 1 will instead retire, the service announced Sunday night, citing his interactions with a subordinate accused of acting inappropriately toward female officers.

Adm. William Moran, the vice chief of naval operations, said in a statement that he will decline his appointment as the next chief of naval operations.

“I made this difficult decision based on an open investigation into the nature of some of my personal email correspondence over the past couple of years and for continuing to maintain a professional relationship with a former staff officer, now retired, who had while in uniform been investigated and held accountable over allegations of inappropriate behavior,” Moran said, without naming the officer.

“To be clear, my decision to maintain this relationship was in no way an endorsement or tacit approval of this kind of conduct,” Moran added. “I understand how toxic it can be to any team when inappropriate behavior goes unrecognized and unchecked.”

Two Navy officials, speaking on the condition of anonymity because of the sensitivity of the issue, said that Moran resigned Sunday after meeting with Navy Secretary Richard V. Spencer.

The officials said the issue emerged after recent Freedom of Information Act requests were made that will lead to scrutiny of Moran’s correspondence with Cmdr. Chris Servello, who was removed from his position as the spokesman for Adm. John Richardson, the chief of naval operations, in August 2017.

The service substantiated allegations that Servello drank heavily at a holiday party at the Pentagon while dressed in a Santa Claus costume and acted inappropriately toward women.

"Specifically, he has shown a pattern of using his outstanding professional reputation and standing in the [public affairs officer] community as an advantage in attempting to develop sexual relationships,” an investigating officer said in a report that was obtained by USA Today and reported on in September 2017. “He has made very strong advances in both cases involving alcohol toward at least two different junior officers (targets) that either have worked for him in the past or see him on a regular basis through the normal conduct professional PAO business.”

Richardson allowed Servello to remain in his job for months after the party as the investigation continued. Servello also had a working relationship with Moran.

Servello, in a statement on Sunday night, said that he was aware of Moran’s decision and that it was “hard not to feel disappointment and disbelief.” He added: “This is terrible news for the Navy. Beyond that I have nothing else to add.”

After being removed as Richardson’s spokesman, Servello served as a public affairs adviser in the military until June 2018.

The specifics of Moran’s emails with Servello are not yet clear; the service has not yet released them.

Spencer said in a statement that Moran’s continuing professional relationship with “an individual who was held accountable and counseled for failing to meet the values and standards of the Navy profession” had prompted him to call Moran’s judgment into question.

“The current Chief of Naval Operations, Adm. John Richardson, will remain the CNO,” Spencer said. “I will make my recommendation for a new CNO candidate to the Acting Secretary of Defense.”