Voters in Turkey’s local elections have delivered a major blow to President Tayyip Erdogan, as the opposition Republican People’s Party make major gains.