MEXICO CITY -- John McCain warned Mexicans that more border walls are needed before he attempts to overhaul U.S. immigration laws again, an unpopular position in a country where he had hoped to boost his standing with Hispanics.

During a trip to Mexico City, the Republican senator also said he opposed unilaterally changing parts of the North American Free Trade Agreement, as liberal Mexican politicians and his rival Barack Obama have suggested.

A year ago, McCain was the co-author of a sweeping immigration-reform bill that had fired hope among millions of Mexicans living illegally in the United States.

That bill stalled in Congress, and instead the United States announced it would expand its border barriers, angering the Mexican government.

"I believe we must have comprehensive immigration reform; the American people want our borders secured first," McCain said during a news conference in Mexico City.

"That will require some walls, it will require virtual fences, it will require high-technology equipment. We must secure our borders and then we will address the issue of comprehensive immigration reform."

Some Mexicans called that the wrong strategy.

"What kind of a good neighbor builds a big wall in your face?" said Salvador Rivera, a clerk in a corner store. "As long as there are jobs in the United States, people are going to find a way up there."

McCain on Thursday wrapped up a three-day trip to Colombia and Mexico, visits aimed at showcasing McCain's foreign-policy credentials while connecting with Hispanic voters.

On Thursday morning McCain visited Mexico's holiest Roman Catholic shrine, the Basilica of our Lady of Guadalupe. The sprawling complex of churches marks the spot where Mary, the mother of Jesus, is said to have appeared to a Mexican Indian in 1531.

Police stood guard outside the main church as McCain laid a wreath of white roses below an Indian tunic bearing the image of Mary. Mexican Catholics believe that her image was miraculously imprinted on the tunic during one of the visions.

McCain, who was raised Episcopalian but now describes himself as a Baptist, was accompanied by his wife, Cindy; former Florida Gov. Jeb Bush; and fellow senators Joe Lieberman and Lindsay Graham.

Such efforts to connect with Hispanics have so far done little to help McCain in the polls. A survey released Wednesday by the Pew Hispanic Center shows Hispanics support Obama over McCain 59 percent to 29 percent. The telephone poll of 1,123 people in June had a margin of error of 3 percentage points.

Some Mexicans said that, despite McCain's attempt at immigration reform, they associate the Republican presidential candidate with other members of his party who have favored a hard line against illegal immigrants.

"Nobody here remembers" that McCain tried to pass an immigration reform bill, said Lucio Lopez, a 54-year-old videographer for television commercials.

"And besides, talking about immigration reform is like putting a rope around your neck in the United States," Lopez said. "It's not like he's going to be able to help our migrants if he gets elected."

Other Mexicans said McCain was tainted by his support for the Iraq war. Mexico has historically been suspicious of U.S. interventions around the world after losing half of its territory to an American invasion in the 1840s.

"McCain, you imperialist pig! Don't mess with our religion!" shouted passer-by Jose Alfonso Corral Correa outside the basilica.

During a lunch with Mexican business leaders, McCain defended the 1994 North American Free Trade Agreement.

Obama has said he would withdraw from NAFTA if Canada and Mexico do not agree to renegotiate certain clauses to protect U.S. jobs. Mexico's opposition Democratic Revolutionary Party has made similar demands, and earlier this year it organized protests to demand more protection for Mexican farmers.

"I am disappointed at the suggestion that the United States should unilaterally re-open NAFTA," McCain said. "If there are issues that exist between our countries -- whether it be the United States, Canada and Mexico … the best way to do that is not in a unilateral fashion, but mutual respect of sovereignty of our respective nations."

McCain also met with President Felipe Calderón and visited a new center where Mexico is training federal agents to fight drug smugglers and terrorists.

As rain pounded on the roof of a helicopter hanger, McCain praised Calderón's efforts to fight drug cartels and pledged continuing support for the Mérida Initiative, a $1.4 billion package of U.S. anti-drug aid. Congress approved the first $400 million of the package last week.

Many Mexicans worry that their country has taken a back seat to Iraq and the U.S. economy during the campaign, said Raul Benitez, professor at the North American Studies Center at the National Autonomous University of Mexico.

"There is a perception that McCain and (Democratic candidate Barack) Obama don't have any kind of policy toward Latin America," Benitez said.

Before leaving Mexico for Phoenix on Thursday, McCain also defended his decision to put Steve Schmidt, a protegé of political guru Karl Rove, in charge of day-to-day campaign operations. It was the second such shakeup in his campaign in the last year.

McCain said Thursday that campaign manager Rick Davis would remain in his job and that the changes were needed because the campaign was growing.

"This is a natural evolution of our campaign as we become more and more of a nationwide campaign with increased staff and increased responsibilities," he said.

Hawley is Latin America correspondent for USA TODAY and The Arizona Republic. Also contributing: The Associated Press