Gunmen opened fire in a mosque in central Afghanistan on Tuesday evening, killing eight worshippers breaking their Ramadan fast and wounding five others, officials said.