The government has said a bill to stop a no-deal Brexit will complete its passage through the Lords on Friday.
The proposed legislation was passed by MPs on Wednesday, inflicting a defeat on Prime Minister Boris Johnson.
There were fears pro-Brexit peers could deliberately hold up the bill so it could not get royal assent before Parliament is prorogued next week.
But the Conservative chief whip in the Lords announced a breakthrough in the early hours after talks with Labour.
The peers sat until 01:30 BST, holding a series of amendment votes which appeared to support predictions that a marathon filibuster session – designed to derail the bill – was under way.
But then Lord Ashton of Hyde made his announcement that all stages of the bill would be completed in the Lords by 17:00 BST on Friday.
He added that the Commons chief whip had also given a commitment that MPs will consider any Lords amendments on Monday and that the government intends that the “bill will be ready to be present for Royal Assent”.
The gaining of Royal Assent for the bill was a requirement that Labour leader Jeremy Corbyn said his party would need before it considered backing Mr Johnson’s call for a general election.
Baroness Smith, Labour leader in the House of Lords, confirmed the opposition supported the move in the Lords overnight, and said she hoped there would be “no further frustrations” of the bill as it goes through all its stages on Friday.
“It has been quite a night. It has been a long debate – and I am grateful to the noble Lords who have stayed the course – it shows the importance of the work we do and the issue we are debating,” she said.
“I am grateful that we are now able to confirm that we will be able to complete all stages of the bill in a time-honoured way by 5pm Friday.”
The agreement was announced after a momentous day in the Commons in which the prime minister suffered defeats over the Brexit bill and his plan for a snap general election.
Mr Johnson had wanted an election on 15 October, but Labour and other opposition MPs would not back the move while the option of a no-deal Brexit on 31 October remained open to the PM.
He needed two-thirds of all MPs to vote in favour, under the rules set by the Fixed Terms Parliaments Act, but after Labour whipped its members to abstain, there were only 298 in favour of the motion and 56 against. That left Mr Johnson 133 short of his target.