The government has been defeated after the House of Lords said ministers should guarantee EU nationals’ right to stay in the UK after Brexit.
The vote, by 358 to 256, is the first Parliamentary defeat for the government’s Brexit bill.
However, MPs will be able to remove their changes when the bill returns to the House of Commons.
Ministers say the issue is a priority but must be part of a deal protecting UK expats overseas.
- Live: Peers debate Brexit bill
- Brexit: All you need to know
- Reality Check: How many EU nationals in the UK?
- UK has ‘moral’ duty to Gibraltar on Brexit
The bill will give Theresa May the authority to trigger Brexit under Article 50 of the Lisbon Treaty and begin official negotiations.
The amendment backed by the Lords requires the government to introduce proposals within three months of Article 50 to ensure EU citizens in the UK have the same residence rights after Brexit.
But it could be overturned when MPs, who have already backed the Brexit bill without amendments, vote on it again.
The government is expected to attempt to overturn the defeat when the legislation returns to the Commons.
The Department for Exiting the EU said: “We are disappointed the Lords have chosen to amend a bill that the Commons passed without amendment.
“The bill has a straightforward purpose – to enact the referendum result and allow the government to get on with the negotiations.”
The government said its position had “repeatedly been made clear”, saying it wanted to guarantee the rights of EU citizens and British nationals “as early as we can”.
BBC political editor Laura Kuenssberg
Government sources tonight sound relaxed.
They knew this vote was likely to go against them. And it’s an issue that the government believes it has a clear defence on.
Indeed, even during Theresa May’s leadership campaign before she moved into Number 10, she articulated the same position. In her view, it would be unwise to guarantee the rights of the three million or so EU citizens in this country, before other EU countries are ready to do the same for British citizens abroad.
For her opponents that’s distasteful, immoral even, because many people who have made their lives in the UK could be used, so the phrase goes, as “bargaining chips” in a negotiation.
There is little sign however of the government giving way despite the defeat.
Ahead of the vote, the government made a last-minute attempt to persuade peers not to change the draft legislation.
Brexit Minister Lord Bridges said the government had been keen to reach an agreement with other EU nations on the issue.
However, he said, “a small number of our European counterparts” insisted there could be no discussions until the formal Brexit talks begin once Article 50 had been invoked.
But most peers wanted a unilateral move from the UK government.
Labour’s shadow Brexit minister Lady Hayter said the concerns of EU nationals here and British expats living in Europe shouldn’t be “traded against each other”.
She added: “These people need to know now – not in two years’ time or even 12 months’ time. They simply can’t put their lives on hold.”
Seven Conservative peers voted in favour of the amendment, which was proposed by Labour with the support of the Liberal Democrats.
Among those opposing it during the sometimes heated exchanges was former Conservative cabinet minister Lord Tebbit, who said the debate seemed to focus on “nothing but the rights of foreigners”.
Shortly after the Lords vote, MEPs in the European Parliament debated the status of EU migrants in the UK.
Justice Commissioner Vera Jourova told MEPs that EU citizens in UK and British citizens elsewhere in the EU “deserve to know that their rights will be” after Brexit.
She said the matter should be addressed “as soon as possible” but that negotiations could only begin after the UK has triggered Article 50.
The stages the Brexit bill needs to go through to become law:
(It is currently at committee stage in the House of Lords)