British Prime Minister Theresa May's government saw off a rebellion by her pro-European MPs on Wednesday after making further concessions over parliament's role in the final Brexit deal.
MPs in the House of Commons voted to reject a motion that would have strengthened the power of lawmakers to intervene if no deal is reached with Brussels before Brexit in March 2019.
Just hours earlier, Brexit Secretary David Davis issued a statement offering a clarification that the rebels said would ensure parliament would have a "meaningful vote."
In the end, MPs voted by 319 to 303 reject a rebel amendment to the EU (Withdrawal) Bill, which sets the legal framework for Brexit.
The government's proposal was passed through without a vote.
Winning the vote is a huge relief for the prime minister, who has struggled to maintain her authority over a deeply divided government.
A defeat would also have been a humiliating setback as she heads to a summit next week with fellow EU leaders, although she still faces tough negotiations with Brussels.
May has offered parliament a vote on the final terms of Britain's withdrawal from the European Union, but has been engaged in months of negotiations over what happens if it is rejected.
Pro-Europeans are determined that parliament be given the opportunity to intervene to stop Britain crashing out of the bloc, which they say could have catastrophic consequences.
But May had warned that any attempt to tie her hands would undermine her chances of a good deal in the Brexit talks, while eurosceptics accused the rebels of trying to block Britain's exit.
The government last week agreed to an amendment stating that if there is no deal by January 21 next year, ministers must put a statement to a vote in parliament.
This vote would be on a "neutral motion," however, meaning it would not be open to any amendments that might force the government into a course of action.
Pro-European rebels in the ruling Conservative party said this rendered the vote meaningless, and warned they would vote against it and instead back their own rebel proposal.
In his last-minute statement, Davis acknowledged that under House of Commons rules, "it will be for the Speaker to determine whether a motion... is or not amendable".
Leading rebel Conservative Dominic Grieve said this was an "obvious acknowledgement of the sovereignty of this place (parliament)," and confirmed he would back the government.
Another rebel, former minister Nicky Morgan, tweeted: "On this basis parliament's vote is meaningful — and I will support govt amendment."
While May won the day, the high-stakes vote is a reminder of how difficult her situation is.
Her Conservative party commands only a slim majority in the 650-seat Commons and relies on the support of Northern Ireland's 10 Democratic Unionist Party MPs.
In a sign of how close Wednesday's vote was, heavily pregnant and sick MPs were called in to cast their ballots, including one in a wheelchair.
Further clashes are due in the coming weeks, notably when bills on Britain's future trading relationship with the EU are debated by MPs.
The main opposition Labour party had backed the rebel amendment on Wednesday but has its own eurosceptic rebels.