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”.
Baroness Smith, Labour leader in the House of Lords, confirmed the opposition supported the move, 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.
The government needed the backing of two-thirds of MPs, but the Commons vote of 298 to 55 in favour was not enough, after the Labour Party whipped its MPs to abstain.