WASHINGTON — The political risks of supporting an immigration overhaul have long been apparent to Senator John McCain, as evidenced by his evolving position on the topic over the years. This week offered another sharp reminder of what getting out in front of the issue can mean when crowds at back-to-back town-hall-style meetings in Arizona turned hostile toward Mr. McCain’s plan to introduce legislation that could lead to legal residency for some who broke the law in entering the country.

“Everybody in this audience, you’re taking away from Social Security to give it to a dependent class of people,” shouted one man, who Mr. McCain eventually called “a jerk.”

The senator, the 2008 Republican presidential nominee, said he was undergoing “an Orwellian experience” as his constituents shouted that he needed to build the “dang fence” that he had once promised in a notable campaign ad. Attendees also suggested that guns were the only way to stop the influx of immigrants from coming across the border.

Like it or not, Mr. McCain is now back at the center of the immigration debate, sharing the spotlight with Arizona’s other senator, Jeff Flake, also a Republican, as the two men help fight to overhaul the nation’s immigration system. Longtime followers of the immigration debate could be forgiven for having déjà vu.