Two police officers suffered slight injuries in the clash, Istanbul governor Davut Gul told reporters on Tuesday.
The assailants were carrying long-barrelled weapons.
Interior Minister Mustafa Cifti wrote on X that the attackers had travelled from the city of Izmit, some 100km east of Istanbul, in a rented car.
One of the assailants was linked to a group he described as "exploiting religion", without naming the organisation.
The Islamic State group has carried out deadly attacks in Turkey in the past.
The two wounded assailants are brothers.
The first has a criminal record related to drugs.
Both are being interrogated, according to the interior ministry.
Video from the attack showed one assailant carrying what appeared to be an assault rifle, wearing a brown backpack, and hiding behind a bus when exchanging fire with police.
A police officer falls to the ground, apparently having been shot, and then rolls away to get behind a tree for cover.
One of the police officers was injured in the leg while the other in the ear, the interior ministry said.
The consulate is located in a high-rise building in Levent, one of the city's main business districts.
Officials said there are no Israeli diplomats present in Israeli missions in Turkey.
Israel withdrew its diplomats amid security concerns and deteriorating relations with Turkey, following the war in Gaza.
Turkey's Justice Minister Akin Gurlek said three prosecutors, including a deputy chief prosecutor, have been assigned to lead an investigation.