Keir Starmer has resigned as British prime minister after nearly two years in office, prompting a Labour leadership race with Andy Burnham among the first to declare his candidacy.