WASHINGTON—Bipartisanship on the divisive issue of immigration is a rarity in Congress, but that is what happened when the House Judiciary Committee unanimously approved legislation making it harder for Indian outsourcing companies to bring high-skilled foreign workers to the U.S.

At the same time, the bill eases rules on some U.S. high-tech firms that use H-1B visas, putting political distance between Silicon Valley and Indian outsourcers as President Donald Trump condemns the program as rampant with abuse and a source of...