A powerful earthquake has rattled northern Afghanistan, killing at least 12 people and damaging one the country’s most beautiful mosques, local authorities said.