WASHINGTON — The House resoundingly rejected a far-reaching immigration overhaul on Wednesday, despite a last-minute plea from President Trump, as internal divisions in the Republican ranks continued to hobble legislative efforts to protect the young unauthorized immigrants known as Dreamers.

The 121-to-301 vote was an embarrassment both to Mr. Trump and to House Republican leaders, who had spent weeks trying to bring together conservatives and Republicans with moderate views on immigration — and ended up with little to show for the effort.

In the end, nearly as many Republicans voted against the bill, 112, as for it, 121.

The defeat provided the latest display of the Republican Party’s disunity in Congress on immigration. And it highlighted the continuing inability of both the House and the Senate to resolve the fate of the Dreamers, who were brought to the country illegally as children. Many of those undocumented immigrants have been shielded from deportation under an Obama-era program, Deferred Action for Childhood Arrivals, or DACA, which Mr. Trump moved last year to end.

Republicans in the House are now likely to turn their focus to narrower legislation that would seek to keep migrant families together at the border, an issue that senators are also looking to address. But with the Fourth of July approaching and lawmakers close to returning home for a recess, it was not clear how quickly a narrower measure might move forward.