Turkey’s local elections on Sunday dealt the biggest blow in more than two decades to President Recep Tayyip Erdogan and his ruling AKP party.