The British prime minister is facing a crisis after his Labour Party suffered election losses.