(Reuters) - The U.S. House of Representatives took its battle over the Trump administration's border wall to federal court on Friday, urging a judge to stop billions of dollars from being transferred towards construction of the barrier without approval by Congress.

"As everyone knows the executive branch cannot build this wall without Congress," Douglas Letter, representing the House, told the U.S. District Court Judge Haywood Gilliam in Oakland, California. "The president asked for $8.1 billion to build the wall and Congress said no to that. This money was clearly denied by Congress under immense pressure."

The House, 20 states and two advocacy groups asked Gilliam to block the transfer of funds to prevent the wall construction.

In February, after a protracted political battle and a government shutdown, Congress approved $1.37 billion for construction of "primary pedestrian fencing" along the border in southeast Texas, well short of President Donald Trump's demands.

To obtain the additional money, Trump declared a national emergency and diverted $601 million from a Treasury Department forfeiture fund, $3.6 billion from military construction and $2.5 billion earmarked for Department of Defense counternarcotics programs.

Trump has said the wall is needed to address a crisis of drugs and crime flowing across the border.

Gilliam questioned both sides about the ability to challenge the transfers and the parameters Congress placed on military funds that were being redirected.

The judge also pressed a government lawyer about the administration's claim the wall qualified as an "unforeseen military requirement" which allowed the money to be used.

"Isn't every request unforeseen?" he asked.

The lawyer said the plaintiffs could not show they would suffer irreparable harm, a condition for blocking the funding, through the mere transfer of the money. He also attacked claims the wall would harm the Mexican wolf migration and said only two wolves were known to have crossed the border in 2017.

Gilliam did not say at the end of the nearly three-hour hearing when he would rule. He asked for added submissions regarding recently announced plans for border construction.

Although it is not a plaintiff, the Democratic-controlled House of Representatives argued in support of the plaintiffs at the hearing.

Trump made the border wall a centrepiece of his 2016 election campaign, when he said Mexico would pay for its construction. That pledge went nowhere, and Trump also hit resistance in Congress even as apprehensions of migrants by border agents hit a decade high as of April.

The hearing comes as the Trump administration has outlined proposals to beef up security along the southwest border and shift immigration policy to favour well-educated English speakers over a system that emphasizes uniting families.