Victory deals blow to prime minister, who will seek third term in power at next year’s general election