US border agents are checking people’s Facebook pages for their political views before allowing them into the country, an immigration lawyer has claimed.

Houston-based lawyer Mana Yegani said several green card holders, who have the right to live and work in the US, were detained by border agents at American airports hours after President Donald Trump signed an executive order banning immigration from seven countries in the Middle East and Africa.

The ban affect travellers with passports from Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen and also extends to green card holders who are granted authorisation to live and work in the United States, according to a Department of Homeland Security spokeswoman.

Protests erupt outside JFK Airport after President Trump's immigration ban

Ms Yegani, who works with the American Immigration Lawyers Association (Alia), said she and her fellow lawyers had worked through the night fielding calls from people with legitimate visa being detained before entering the US or ordered back on flights to the Muslim-majority countries on the list.

In one alleged incident a Sudanese PhD student at Stanford University in California, who has lived in the US for 22 years, was held for five hours in New York and in another a dual Iranian-Canadian citizen was not allowed to board a flight in Ottawa.

The Alia said border agents were checking the social media accounts of those detained and were interrogating them about their political beliefs before allowing them into the US.

She said: "These are people that are coming in legally. They have jobs here and they have vehicles here.

"Just because Trump signed something at 6pm yesterday, things are coming to a crashing halt. It's scary."

The controversial orders Donald Trump has already issued Show all 9 1 /9 The controversial orders Donald Trump has already issued The controversial orders Donald Trump has already issued Trump and the media White House Press Secretary Sean Spicer takes questions during the daily press briefing Getty Images The controversial orders Donald Trump has already issued Trump and the Trans-Pacific Partnership Union leaders applaud US President Donald Trump for signing an executive order withdrawing the US from the Trans-Pacific Partnership negotiations during a meeting in the Roosevelt Room of the White House in Washington DC. Mr Trump issued a presidential memorandum in January announcing that the US would withdraw from the trade deal Getty The controversial orders Donald Trump has already issued Trump and the Mexico wall A US Border Patrol vehicle sits waiting for illegal immigrants at a fence opening near the US-Mexico border near McAllen, Texas. The number of incoming immigrants has surged ahead of the upcoming Presidential inauguration of Donald Trump, who has pledged to build a wall along the US-Mexico border. A signature campaign promise, Mr Trump outlined his intention to build a border wall on the US-Mexico border days after taking office Getty Images The controversial orders Donald Trump has already issued Trump and abortion US President Donald Trump signs an executive order as Chief of Staff Reince Priebus looks on in the Oval Office of the White House. Mr Trump reinstated a ban on American financial aide being granted to non-governmental organizations that provide abortion counseling, provide abortion referrals, or advocate for abortion access outside of the United States Getty Images The controversial orders Donald Trump has already issued Trump and the Dakota Access pipeline Opponents of the Keystone XL and Dakota Access pipelines hold a rally as they protest US President Donald Trump's executive orders advancing their construction, at Columbus Circle in New York. US President Donald Trump signed executive orders reviving the construction of two controversial oil pipelines, but said the projects would be subject to renegotiation Getty Images The controversial orders Donald Trump has already issued Trump and 'Obamacare' Nancy Pelosi who is the minority leader of the House of Representatives speaks beside House Democrats at an event to protect the Affordable Care Act in Los Angeles, California. US President Donald Trump's effort to make good on his campaign promise to repeal and replace the healthcare law failed when Republicans failed to get enough votes. Mr Trump has promised to revisit the matter Getty Images The controversial orders Donald Trump has already issued Donald Trump and 'sanctuary cities' US President Donald Trump signed an executive order in January threatening to pull funding for so-called "sanctuary cities" if they do not comply with federal immigration law AP The controversial orders Donald Trump has already issued Trump and the travel ban US President Donald Trump has attempted twice to restrict travel into the United States from several predominantly Muslim countries. The first attempt, in February, was met with swift opposition from protesters who flocked to airports around the country. That travel ban was later blocked by the Ninth Circuit Court of Appeals. The second ban was blocked by a federal judge a day before it was scheduled to be implemented in mid-March SANDY HUFFAKER/AFP/Getty Images The controversial orders Donald Trump has already issued Trump and climate change US President Donald Trump sought to dismantle several of his predecessor's actions on climate change in March. His order instructed the Environmental Protection Agency to reevaluate the Clean Power Plan, which would cap power plant emissions Shannon Stapleton/Reuters

A spokesman for the Alia told The Independent that they had heard were anecdotal reports of people’s social media accounts being targeted – this tactic had been used by border agents for several years despite doubts over whether it is constitutional.

It comes as several immigration organisations and the American Civil Liberties Union (ACLA) launched a lawsuit in New York on behalf of two Iraqi men, one a former US government worker and the other the husband of a former US security contractor.

It said they had been given visas to enter the US but were detained at JFK airport hours after Mr Trump issued the executive order.

Meanwhile in Cairo, five Iraqis and one Yemeni passenger were barred from boarding a connecting EgyptAir flight to New York and were redirected to flights back to their home countries, despite holding valid visas.

Dutch airline KLM said it had similarly refused carriage to seven passengers from Muslim countries because there was “no point taking them to the US”.

May refuses to condemn Muslim ban

The order, signed on Holocaust Memorial Day, means Syrian refugees have been banned from entering the country indefinitely – though the White House has said it will consider admitting Syrian Christians – and the entire US refugee programme has been suspended for 120 days.

Nationals from the six other countries on the list have been banned from entering the US for 90 days.

The move has been condemned by the UN’s refugee agency (UNHCR) and the International Organisation for Migration who said: “The needs of refugees and migrants worldwide have never been greater and the US resettlement program is one of the most important in the world,”

“The longstanding US policy of welcoming refugees has created a win-win situation: it has saved the lives of some of the most vulnerable people in the world who have in turn enriched and strengthened their new societies.”