The Republican-written bill, approved on a vote of 283-138, calls for construction of about 1,127km of fence along the 3,200km border with Mexico. Democratic opponents said the measure was a charade designed to help Republicans ahead of the November 7 elections.
Steny Hoyer, a Maryland Democrat, said: "This is to score political points that are going to be demagogued in 30-second ads."
He accused Republicans of trying to appeal to the "fears and passions" of people. He and other Democrats called for a broad immigration overhaul along the lines of the bill passed by the US Senate that would create a guest worker programme and legalise millions of illegal immigrants.
George Bush, the US president, backs comprehensive legislation and a guest worker programme and spoke about the need for it during a meeting with House Republicans at the Capitol on Thursday.
But the issue divides Republicans. Many feel the Senate bill would grant amnesty to people who broke US law and it is unlikely a broad immigration bill will be passed this year.
Instead, House Republican leaders plan to pass a series of border security measures before lawmakers break at the end of the month to campaign for the elections.
Dennis Hastert, the House speaker and an Illinois Republican, said the fence and other efforts would be added to a domestic security spending bill for next year that the House and Senate are hoping to finish by the end of the month.
Republican supporters of the fence said it was a step toward controlling the borders and would help stem the flow of illegal immigration while reducing drug smuggling and other crimes.
An estimated 1.2 million illegal immigrants were arrested in the last fiscal year trying to cross into the United States along the border states of Texas, New Mexico, Arizona and California. Sections of the fence will be built in each state.
Duncan Hunter, a California Republican who heads the House Armed Services Committee, said: "We have to know who is coming across our borders and what they are bringing with them."
Hastert said after the vote: "If we build it, they will no longer come illegally."
But even some Republicans opposed the piecemeal approach.
Jim Kolbe, an Arizona Republican, said: "We're really not debating anything of substance. This is a feel good piece of legislation."