According to local medias, the incident occurred at around 1.00 p.m. local time (1000 GMT) in the Sariyer district, on the city's European side.
Istanbul Chief Public Prosecutor Hadi Salihoglu said in a statement that the man jumped on security guards to coerce them into helping him meet President Recep Tayyip Erdogan.
Erdogan was not in the building at the time.
The as-yet-unidentified man told security staff: "Help me meet with Erdogan and open the doors," Salihoglu's statement read.
The man then snatched a weapon from a security guard, firing shots at police before turning the gun on himself, a presidential statement read.
No security personnel were injured during the incident.
An investigation is underway.
Source: Agencies