Mexican President Vicente Fox has praised the US Senate for passing an immigration bill he called "a monumental step forward".
Vicente Fox divided opinion in the California legislature
The bill paves the way for millions of illegal migrants to seek citizenship, although it must be reconciled with tougher measures passed in the House.
Mr Fox, on a four-day trip to the US, said this was "a moment that millions of families have been hoping for".
About 11.5m illegal immigrants live in the US, many of them Mexicans.
Mr Fox said in an address to the California legislature in Sacramento late on Thursday: "This is the moment that millions of people have been working for.
"Today's historic vote is a monumental step forward, but we recognise that there is more debate ahead."
As with the issue itself, Mr Fox's visit has polarised opinion.
Some California legislators boycotted his speech, while other wore "No mas" (No more) badges in opposition to further illegal immigrants.
One southern California legislator, Todd Spitzer, said: "His country should be up in arms. He is responsible for splitting families and didn't make a dent in the problems during his six years in office."
However, Mr Fox was broadly welcomed by Democrats and by Governor Arnold Schwarzenegger, who is seeking to shore up the Hispanic vote ahead of autumn elections.
Assembly Speaker Fabian Nunez said: "[Mr Fox's] message was a good one. It stressed shared responsibility."
The US Senate voted 62-36 to approve the legislation, which also includes measures to increase border security.
Immigrant groups have held rallies in support of the reforms
The bill is backed by President George W Bush - but will have to be reconciled with measures approved by the House of Representatives last year that would criminalise illegal immigration and impose tougher enforcement measures.
The issue of immigration is key as Republicans seek to retain control of Congress in November's mid-term polls.
The debate has also energised the streets, with hundreds of thousands of people - many of them Hispanic - demonstrating in Los Angeles, Chicago and elsewhere.
They are demanding recognition for the role they say immigrant workers play in the American economy.
Anti-immigration groups have, meanwhile, begun patrolling US borders and confronting illegal workers in cities around the US.
The Senate bill combines tougher border security with ways of allowing some illegal immigrants to seek US citizenship, and provisions for guest-worker programmes.
"Why not say to those undocumented workers who are working the jobs that the rest of us refuse, 'come out from the shadows'," said Arizona Senator John McCain, a Republican and leading supporter of the bill.