After days of street demonstrations that stretched from California to the grounds of the US Capitol, a coalition of Democrats and Republicans also agreed to strip out proposed criminal penalties for residents found to be in the US illegally.
Senator Edward Kennedy, the Massachusetts Democrat who played a pivotal role in drafting the legislation, said: "All Americans wanted fairness, and they got it this evening."
The legislation must still pass the full Senate and its differences with the House of Representatives must be resolved before a final act is sent to George Bush, the president, for signing into law. That will probably take months.
In the heavily partisan current US Congress, the 12-6 committee vote was unusual.
A majority of Republicans opposed the proposal even though their party controls the Senate, but the Republican committee chairman, Senator Arlen Specter of Pennsylvania, voted for it.
At several critical points, committee Democrats showed unity while Republicans splintered.
In general, Republican Senators Lindsey Graham of South Carolina, Sam Brownback of Kansas and Mike DeWine of Ohio, who is seeking re-election this autumn, sided with Democrats. That created a majority that allowed them to shape the bill to their liking.
Even as he voted for the bill, Specter signalled that some of the provisions could well be changed by the full Senate in the debate that begins there on Tuesday.
The bill is designed to strengthen the border patrol, create new opportunities for so-called guest workers and determine the legal future of the estimated 11 million immigrants living in the US illegally.
Tens of thousands of students walked out of school in California, Texas and other states, waving flags and chanting slogans in a second week of protests against legislation to crack down on illegal immigrants.
In Washington DC, 100 demonstrators wore handcuffs at the Capitol on Monday to protest against a bill that would make it a crime to dispense aid to illegal immigrants.
Immigrant supporters also object to legislation that would also impose new penalties on employers who hire illegal immigrants and would build fences along part of the US-Mexican border.
More than 500,000 people gathered in downtown Los Angeles on Saturday, and tens of thousands rallied in Phoenix and Milwaukee last week.
On Monday, 36,000 students marched out of Los Angeles-area schools, officials said.
By midmorning, the protests had spread to downtown, where hundreds of students walked the streets and chanted.
The boycott had the tacit approval of school officials in some of the heavily Hispanic downtown schools, where word was passed through hall posters and public address systems.
In purely political terms, the issue threatened to fracture Republicans as they head into the congressional election campaign: One group is eager to make labour readily available for low-wage jobs in industries such as agriculture, construction and meatpacking; the other is determined to place a higher emphasis on law enforcement.
That was a split Bush was hoping to avoid after a political career spent building support for himself and his party from Hispanics, now the largest minority population in the country.