The blast, which struck the Jawadia mosque, coincided with evening prayers at around 20:00 local time (15:30 GMT).
Officials said there were at least two attackers - one a suicide bomber, and another who shot at worshippers with a firearm.
A spokesperson for the local governor told the BBC the death toll could rise.
He said at least 29 people had been killed, and another 64 were injured.
Both attackers are dead, a police spokesperson told AFP news agency.
The governor's representative said the suicide attacker also opened fire inside the mosque before detonating his explosives.
Reuters reported grenades were thrown, citing local police.
The state broadcaster in neighbouring Iran, IRIB, said that seven gunmen were involved. The report has yet to be confirmed by local sources in Afghanistan.
No group has said it was behind attack, which occurred in a predominantly Shia Muslim area. A spokesman for the Taliban, which has struck Shia mosques in the country before, condemned the attack in a text message sent to reporters.
Herat, close to the border with Iran, is considered one of Afghanistan's more peaceful cities.
Photo: AFP (The explosion caused significant damage inside the mosque at prayer time)