During the hearing, US District Judge Jon Tigar in San Francisco federal court repeatedly grilled Justice Department attorney on whether President Trump's move was justified.
Last week the Trump administration had sharply limited migrant asylum seekers to enter the US effectively banning all those who entered illegally from the US border from Mexico.
"To say something is true does not make it true," Tigar said during the hearing while questioning the government's lawyer.
Tigar said Congress had stated that immigrants can apply for asylum regardless of how they entered the country. The judge called the latest rules an "extreme departure" from prior practice.
Tigar issued a temporary restraining order against Trump's order.
"Whatever the scope of the President's authority, he may not rewrite the immigration laws to impose a condition that Congress has expressly forbidden," the judge said while hitting out at the Trump administration.
President Trump has sent over 5,000 troops to the Mexico border in an attempt to stop asylum seekers, a move which was criticised both by Democrats and Rights Groups.
Meanwhile, several hundred central American migrants have been pouring into the Tijuana on the Mexican side of the US border which is being called the "migrant caravan" by the US president who has threatened to use force if they try to forcibly enter the US.
Trump had admonished the "migrant caravan" heading to the US terming it as an "invasion" threatened American national security.
Thousands of Central American migrants had begun a journey from Honduras through Mexico toward the United States to seek asylum as many others including Salvadorans.
Last week the Trump administration had sharply limited migrant asylum seekers to enter the US