Turkey’s ruling AK Party failed to win an outright majority, dealing a blow to Tayyip Erdogan’s ambitions.