Jeremy Corbyn survived a Labour revolt over Brexit as the party's conference backed his policy of remaining neutral until after a general election.
The Labour leader has promised that a government he leads will negotiate a new Brexit deal and put it to a referendum but he has resisted calls to say how the party should campaign in that public vote.
Delegates at the conference in Brighton backed a statement setting out his position and broke out into a chorus of "oh, Jeremy Corbyn" after the result of the vote was announced.
In chaotic scenes, the conference then rejected a motion which would have called on Labour to come out in support of Remain now rather than waiting until after an election.
The result is a boost for Mr Corbyn, who has argued that Labour should go into the expected general election without making a decision on how it should campaign on the referendum his party has promised within six months of taking office.
A decision on how the party would campaign in the referendum would be taken at a subsequent special conference.
The vote came after shadow cabinet ministers Emily Thornberry and Sir Keir Starmer both used their keynote conference speeches to say they would back Remain.
After delegates backed a statement from the ruling National Executive Committee in favour of Mr Corbyn's position, a vote followed on composite 13 – which called for Labour to "campaign energetically" for a second referendum and to stay in the EU in such a public vote.
I do not believe this decision reflects the views of the overwhelming majority of Labour members who desperately want to stop Brexit. Labour IS a Remain party.
I will continue campaigning with @LondonLabour to give the public the final say and stop Brexit.
- Sadiq Khan (@SadiqKhan) September 23, 2019
It was announced this motion was defeated following a show of hands among delegates allowed to vote.
Wendy Nichols, who was chairing the afternoon session of Labour conference, said there was disagreement in the group on stage looking at proceedings.
As delegates cast their votes, the chairwoman Ms Nichols could be seen having a discussion with Labour general secretary Jennie Formby.
Announcing the result, Ms Nichols said: "Sorry I thought it was one way... and Jennie said something else, so.
"Yes, that was lost."
- Diane Abbott (@HackneyAbbott) September 23, 2019
Further confusion followed, with Ms Nichols reiterating the motion was rejected despite appeals for a formal card vote by some members.
Andrew Lewin, of the Remain Labour campaign, said the party now faced going into a general election without a clear position.
He told the PA news agency: "We are going to be unable to answer the question 'are you for Remain or Leave'.
"Obviously, lots of good people and senior people like Keir Starmer, Emily Thornberry etc. are going to say individually, but that's not what the public will see.
"The public will see the leader – and therefore by definition a party – that can't make its mind up and I think that will be really damaging."
SNP Europe and foreign affairs spokesman Stephen Gethins said: "Jeremy Corbyn is stuck firmly on the fence, refusing to come down – and today's votes show the rest of the Labour Party is happy to stay there. This is a real abdication of leadership.
"It beggars belief that more than three years after the EU referendum, and knowing the damage Brexit will do, Labour is still arguing over its position."