Both candidates support an eventual path to citizenship for illegals
US presidential rivals Barack Obama and John McCain have clashed over their commitment to immigration reform.
Addressing a conference of Hispanic officials in Washington, Mr McCain, the Republican candidate, said the US must secure its borders.
Mr Obama, the Democratic Party candidate, said he admired Mr McCain's attempt last year to get an immigration reform bill approved by Congress.
But he said that Mr McCain had since walked away from that commitment.
Mr McCain was one of the few Republican senators to back President Bush's comprehensive immigration plan which contained an amnesty for some illegal immigrants.
Speaking before some 700 Hispanics attending the National Association of Latino Elected and Appointed Officials conference Mr McCain paid his respects to Hispanic-Americans.
"I know this country... would be the poorer were we deprived of the patriotism, industry and decency of those millions of Americans whose families came here from Mexico, Central and South America," he said.
He added that his primary focus regarding immigration reform was to secure the United States border with Mexico.
"We will not succeed in the Congress of the United States until we convince a majority of the American people that we have border security," he said.
"But that does not have to be done in an inhumane or cruel fashion," he added.
Mr McCain's speech was disrupted several times by hecklers from an anti-war group.
'Nation of immigrants'
Appearing later before the same audience, Mr Obama accused Mr McCain of walking away from comprehensive immigration reform.
"When he was running for his party's nomination, he walked away from that commitment. He said he wouldn't even support his own legislation if it came up for a vote," Mr Obama said.
"If we are going to solve the challenges we face, we can't vacillate, we can't shift depending on our politics."
"We must assert our values and reconcile our principles as a nation of immigrants and a nation of laws. That is a priority I will pursue from my very first day," he added.
Mr McCain's campaign team later issued a statement saying Mr Obama had worked to defeat last year's reform attempt by voting for amendments that the bill's Democratic sponsors opposed.
Hispanic votes are concentrated in several key states, including Florida, Arizona, Nevada and Colorado.
In 2004, President Bush won about 40% of the Hispanic vote, a Republican record. But recent elections have shown that the Hispanic vote has returned to its Democratic leanings.