Reports from the scene said a number of soldiers, some of them American, were wounded.
At Herat main hospital, Dr Shehrzai confirmed that 29 bodies were brought to the medical facility soon after the blast.
More than 1,700 civilians have been killed in attacks in Afghanistan so far this year, hitting confidence in the Western-backed government of President Ashraf Ghani.
The terror group issued a statement late on Wednesday claiming that the attack on Jawadia mosque was carried out by two of their suicide bombers identified as Umair Asim and Tayyeb Al-Khurasani.
The Pentagon says that two US service members were killed in an attack on a North Atlantic Treaty Organisation convoy near Kandarhar in southern Afghanistan.More news: Barack and Michelle Obama Still Write Responses to White House Fan Mail
The attack took place in the middle of evening prayers when the mosque was packed with about 300 worshippers.
"US Forces Afghanistan will provide additional information as it becomes available".
Relatives inspect after an overnight suicide attack at a mosque in Herat, Afghanistan.
Several casualties are feared in the attack that destroyed at least two North Atlantic Treaty Organisation vehicles in the outskirts of Kandahar city, said Zia Durrani, spokesman for the Afghan police in the region.
He said that the convoy near a base of the Afghan spy agency National Directorate of Security had been attacked.