Labour faces a “long haul” as it attempts to gain power following its fourth election defeat in a row, shadow chancellor John McDonnell has warned.
He rejected claims that leader Jeremy Corbyn had been responsible for the result, instead blaming “the overwhelming issue” of Brexit.
But some current and ex-MPs have said Mr Corbyn’s unpopularity contributed to Labour losing dozens of seats.
Boris Johnson’s Conservatives won on Thursday with a Commons majority of 80.
The outcome, far more positive for the Tories than most opinion polls had predicted, has prompted much soul-searching within Labour, which last won a general election under Tony Blair in 2005.
Mr Corbyn has announced he will stand down in the near future and Mr McDonnell, one of his closest allies, said he had been “the right leader” for the party.
But Labour’s Helen Goodman, who lost her Redcar seat to the Conservatives on Thursday, told BBC Radio 4’s Today programme that “the biggest factor was obviously the unpopularity of Jeremy Corbyn as the leader”.
And Dame Margaret Hodge, Labour MP for Barking, east London, said she felt “anger because this is an election we should have won”.
She added that, under Mr Corbyn’s leadership – during which Labour has faced criticism for its handling of anti-Semitism allegations among its membership – voters had come to see it “as a nasty party”.
Wes Streeting, Labour MP for Ilford North, said the party’s “far-left” manifesto had alienated much of the electorate.
However, Labour’s ex-Welsh secretary, Lord Hain, insisted the party must not embrace a “wishy-washy centrism” in the wake of its defeat.
Lord Hain, a cabinet minister under both Tony Blair and Gordon Brown, said the “Corbyn project” had some “very searching self-examination” to do, but it was important to offer “a clear alternative to the Tory project”.
Mr McDonnell disagreed with personal criticism of his leader, saying: “The overwhelming issue was Brexit and the Labour Party was caught on the horns of a dilemma.
“We had a party which was largely supportive of Remain, but many of us represented Leave constituencies.”
In the election, Labour’s number of Commons seats fell to 203, its lowest since 1935.
Mr Corbyn, leader since 2015, ran for prime minister on a promise to hold a second referendum on Brexit, saying that during any campaign he would remain neutral – in contrast to Mr Johnson’s promise to take the UK out of the EU by 31 January.
Mr McDonnell said: “If we went one way, to Leave, we would have alienated a lot of our Remain support. If we went for Remain, we’d alienate a lot of our Leave support.
“We tried to bring the country together. It failed. We have to accept that, take it on the chin. We have to own that and then move on.”
Mr McDonnell, MP for Hayes and Harlington in west London, said Labour now needed to have “a constructive debate” about its future, discussing “what went right and what went wrong” during the election campaign.
He argued that Mr Corbyn, who has received criticism from some Labour figures for not standing down immediately, was right to stay on “for a couple of months”.
It was necessary because of the “expertise” required to deal with issues such as Brexit and the forthcoming Budget, he said.
Discussing Mr Johnson’s government, Mr McDonnell said: “My fear is that we’re in for a long haul now, possibly five years.
“The two issues that we face are still there – huge, grotesque levels of inequality and, the issue that never really emerged in the campaign, which was climate change, this existential threat that must be our priority.
“Brexit, well, we’ll see what the government brings back in terms of its negotiations. The people have decided we need to implement that, but we’ve got to get the best deal to protect jobs and the economy.”
He added: “My fear is five years of a fossil fuel-backed government under Boris Johnson means we’ll miss this five-years opportunity of saving our planet.”
At the 2017 general election, Mr Corbyn’s first as Labour leader, the party won 40% of votes and gained 30 MPs, denying Theresa May’s Conservatives a majority.
But on Thursday it received 32% of the vote and lost 59 seats, including several of its traditional strongholds in the north of England.
Mr Corbyn said that, during the election campaign, he had done “everything I could” and that he had “pride” in the party’s manifesto.
The Labour leader’s sons, Tommy, Seb and Benjamin, tweeted a tribute to their father, calling him an “honest, humble and good-natured” figure in the “poisonous world” of politics.