Demonstrators in Pollokshields, blocked the immigration enforcement van for hours on Thursday, with one lying underneath the vehicle.
Around 200 protesters were at the scene in Kenmure Street, with chants of “Leave our neighbours, let them go” and “Cops go home” being heard as a ring of police stood around the van.
Staff from Immigration Enforcement are believed to have swooped on a property in the area on Thursday morning and detained people.
Shortly after 5pm, Police Scotland released a statement saying the men would be released.
It followed the protests, pressure from human rights groups and politicians including Scotland first minister Nicola Sturgeon, who is the area’s constituency MP.
Ms Sturgeon accused the Home Office of creating “a dangerous and unacceptable situation” with the action.
After the men’s releases, she Tweeted: “The Home Office needs to ask itself hard questions after today. Doing this on Eid, in the heart of our Muslim community, and in the midst of a serious Covid outbreak was staggeringly irresponsible - but the even deeper problem is an appalling asylum & immigration policy.”
She added: “I am proud to represent a constituency and lead a country that welcomes and shows support to asylum seekers and refugees.”
As cheering protesters escorted the released men to the local mosque, Pinar Aksu, of Maryhill Integration Network said: “They messed with the wrong city.”
One of the men, Lakhvir Singh, 34, from India, spoke to the PA news agency through a translator.
He said: “I’ve been astonished and overwhelmed by the support I’ve received from the people of Glasgow.
“At around 9.30am immigration enforcement carried out a raid and we were taken to security in the van.
“There were only five or six people at the time but word spread and then there were crowds of hundreds.
“We are so grateful for the support.”
Scottish Justice Secretary Humza Yousaf said the Home Office’s actions had been “reckless”.
Saying that immigration was a reserved issue, he tweeted: “Situation should never have occurred – the UK Govt’s hostile environment is not welcome here”.
He added: “I abhor Home Office immigration policy at the best of times, but to have taken the action they have today is at best completely reckless, and at worst intended to provoke.”
A Police Scotland statement said Superintendent Mark Sutherland had decided to release the detained men “in order to protect the safety, public health and wellbeing of those involved in the detention and subsequent protest”.
The force asked those nearby to disperse from the area as soon as possible.
A spokeswoman said earlier: “Police Scotland does not assist in the removal of asylum seekers. Officers are at the scene to police the protest and to ensure public safety.”
Mohammad Asif, director of the Afghan Human Rights Foundation, was one of what he said were hundreds of neighbours protesting against the action on Thursday.
The 54-year-old told the PA news agency earlier on Thursday: “We’re here against the hostile environment created by the Tories and the British state.
“The same people who run from the British and American bombs put at the back of the van right now. And they are about to be deported.
“And it’s on Eid you know … the guys are not even allowed to pray. How do you do that in a democratic society? It’s a sad day.”
Mr Asif, who left Afghanistan as a refugee himself in 2000, said the atmosphere among the protesters was peaceful.
Wafa Shaheen, head of services at the Scottish Refugee Council, said she was “shaken and angry” at the Home Office’s decision to “force people from their homes on the first day of Eid” and she condemned the “heavy-handed approach”.
Tom, a neighbour who joined the protest, compared the immigration operation on Eid to a police raid on Christmas Day.
“The solidarity shown today shows the community will not stand for their neighbours being dragged from their homes,” the 31-year-old, who did not want to give his surname, told PA.
“I’d ask Christians to reflect on what it would feel like to have your house raided on Christmas Day.”
Lotte, an artist and member of the Scottish tenants union Living Rent, lives on a street nearby. She said she joined the protest when she saw a small group outside the property on Kenmure Street at 10am on Thursday.
“I’d like to express my utter disgust at the brutal removal of my neighbours from their home,” the 26-year-old said.
“It is an awful thing to do on any day, but today being Eid makes it 10 times worse. I hope they will let our neighbours go.”
Scottish Labour leader Anas Sarwar said he was “disgusted by the Home Office raids”.
He tweeted: “It is particularly unacceptable that this is happening during a pandemic, in an area that has a spike in cases and on the day of Eid.”
Home Office spokesperson said: “The UK Government is tackling illegal immigration and the harm it causes, often to the most vulnerable people by removing those with no right to be in the UK.
“The operation in Glasgow was conducted in relation to suspected immigration offences and the two Indian nationals complied with officers at all times.
“The UK Government continues to tackle illegal migration in all its forms and our New Plan for Immigration will speed up the removal of those who have entered the UK illegally.”