Ministers have said it would be wrong to give a guarantee without a similar deal for Britons abroad, which they say they will seek in Brexit negotiations.
But the Commons backed a Labour motion urging a rethink by 245 votes to two, as government MPs largely abstained.
Leading Leave campaigner Boris Johnson was among several Tory rebels to vote against the government.
The government had tried to avoid a Commons vote because defeat seemed likely - but Labour forced a division following its opposition day debate.
The motion is not binding on the government but it acts as a signal of MPs' views on the subject.
Mr Johnson supported Labour's call for ministers to "commit with urgency" to giving the estimated three million EU nationals in the UK the right to remain after the country has left the EU.
He told MPs: "I would like to set on record that countless times the Vote Leave campaign gave exactly this reassurance to people from other EU countries that live and work here and it is very disappointing that this is being called into question.
"It think it's absolutely right to issue the strongest possible reassurance to EU nationals in this country, not just for moral or humanitarian reasons, but very, very sound economic reasons too.
"They are welcome, they are necessary, they are a vital part of our society and I will be passionately voting for this motion tonight."
Home Secretary Theresa May, who backed staying in the EU, has been criticised - including by many Conservative MPs - for failing to guarantee EU citizens already in the UK the right to remain.
She has said the issue will play a part in negotiations with the EU, as the UK maps out its withdrawal.
Shadow home secretary Andy Burnham accused Mrs May of using EU citizens as "bargaining chips".
He claimed Mrs May was trying to "woo" Conservative Party members in her bid to become the next leader and prime minister.
Criticising her absence from the debate, Mr Burnham accused Mrs May of an "abdication of leadership".
But immigration minister James Brokenshire - who faced criticism from MPs across the political spectrum over the government's stance - rejected the claim it was treating EU citizens as "bargaining chips".
"In the approach the government takes and the agreements we make, we will never treat EU citizens as pawns in some kind of cynical game of negotiation chess."
He said the government's aim was to secure a "fair deal" for EU nationals in the UK and Britons living abroad in other European countries.
In a statement on Wednesday evening after the Commons vote, Mr Burnham said MPs' decision was "a victory for common sense and decency".
"With this emphatic result, it is impossible to see how the government can now reverse what is the clear will of the House of Commons.
"Theresa May should accept the decision of the House and confirm the legal status of EU nationals without delay," he added.
MPs have put pressure on the government to guarantee EU nationals living in the UK the right to stay after Brexit.