A top aide to Mayor Bill de Blasio had his iPhone swiped from his hand as he rode a Manhattan subway this week, police sources said Wednesday.

Mahen Gunaratna, 30, Hizzoner’s deputy communications director, was robbed Tuesday at about 5:20 p.m. after he boarded a Brooklyn-bound train on the 4 and 5 line at 14th Street-Union Square station, sources said.

Gunaratna was holding onto a subway pole with his right hand and holding his phone in his left when the train pulled into the Fulton Street station – two stops from where he got on, according to sources.

Just as the doors were about to close, one of two thieves snatched his phone and both crooks fled out of the train.

The quick-thinking victim chased the suspects out of the station, but he lost sight of them at the street level, sources said.

Police described the suspects as two men about 5 feet 8 and 140 pounds.

No arrests have been made.

It is unclear if the stolen cellphone was a work phone or a personal phone.

Gunaratna refused to discuss the incident when asked by The Post at City Hall, and referred questions to the press office.

“It’s certainly unsettling and a major inconvenience,” de Blasio spokesman Eric Phillips said in an email.

Phillips added: “Mahen was on the train and someone grabbed his phone and took off. He gave chase but lost them somewhere on Broadway.”

At a March 2016 press conference, de Blasio was quoted as saying, “You have an almost million in one chance of being a victim of any kind of crime on the New York City subways and most of those crimes are property crimes.”

Gunaratna has worked as de Blasio’s deputy communications director since January, according to his LinkedIn profile.

Before that he worked as the director of research and media analysis for the de Blasio administration between January 2014 and January 2016, but left that post to work on Hillary Clinton’s presidential campaign.

Additional reporting by Yoav Gonen