The prime minister quits as Tory leader but says he will continue to serve until the party chooses his successor