The intervention by the former prime minister comes just weeks before a key by-election that could determine Labour’s future.