Correction: An earlier version of this article incorrectly said that the Immigration Reform Law Institute, for which Michael Hethmon is general counsel, was labeled a “hate group” by the Southern Poverty Law Center. The SPLC applied that designation to the IRLI’s parent organization, the Federation for American Immigration Reform. This version has been corrected.

They were a mismatched pair who somehow managed to re­arrange the national immigration debate and the half-shadow world in which illegal immigrants live and work in the United States.

One, Kris Kobach, was a telegenic law professor who was worried about foreign terrorists. The other, Michael Hethmon, was a bookish lawyer afraid that immigrants would overburden the environment.

Over the past six years, the two have become the most successful propagators of a powerful idea: that state and local governments can make life so miserable for illegal immigrants that they would choose to deport themselves.

During this year’s Republican presidential primary contest, the notion of self-deportation began to take on new legitimacy. Mitt Romney, the party’s presumed nominee, praised the idea and has pledged that he would drop the Obama administration’s challenges to state laws in places such as Alabama and Arizona.

Kobach and Hethmon have helped six states and at least seven cities and counties write tough legislation that allows local police or bureaucrats to crack down on illegal immigrants. Usually, that’s a function reserved for the federal government, but these two lawyers said they knew the “magic words” of legalese to make local laws work.

“We are constantly told that the only two options are massive roundups [of illegal immigrants] or an amnesty. But attrition through enforcement is the third way,” said Kobach, the better-known of the pair. “Change the individual decisions of particular illegal aliens, and they will decide to leave the country.”

Hethmon worries about cultural shifts that could result.

Immigration is “on track to change the demographic makeup of the entire country. You know, what they call ‘minority-majority,’ ” said Hethmon, who is general counsel at the Washington-based Immigration Reform Law Institute, whose parent organization, the Federation for American Immigration Reform, was designated a “hate group” by the Southern Poverty Law Center, “How many countries have gone through a transition like that — peacefully, carefully? It’s theoretically possible, but we don’t have any examples.”

Now, however, is their time of trial. Judges have blocked some of the legislation, resulting in a pile of legal bills for the governments they helped, and on Wednesday the U.S. Supreme Court will hear arguments about the law in Arizona that has become the centerpiece achievement of the self-deportation movement.

Supporters say the idea would never have advanced this far without Kobach and Hethmon, who have been editors, advisers, ghostwriters and legal defenders for politicians nationwide.

“They’re the wizards behind the curtain,” said Oklahoma state Rep. Randy Terrill (R), whose bill they rewrote. “They were the face and the muscle behind the effort that really synthesized it into a movement. Do I think it would have happened without them? Most certainly it would not have.”

Their role behind the curtain began in 2006, with a phone call from Hazleton, Pa.

That old coal town had swelled with thousands of Latino immigrants. Then-Mayor Lou Barletta blamed illegal residents for a surge in crime, saying he was paying for the failures of the federal immigration system. That year, the United States had an estimated 11.6 million “unauthorized immigrants.” The federal system deported about 272,000 people.

Barletta wrote an ordinance that punished people who hired illegal immigrants or rented apartments to them. In the furor that followed, he noticed a supportive quote in a newspaper from a law professor at the University of Missouri at Kansas City.

His secretary placed the call. Kobach picked up: “What took you so long?”

Kobach, 46, has a strong chin, a quarterback’s build, and degrees from Harvard, Oxford and Yale. He says his focus on immigration came from working in the Justice Department on Sept. 11, 2001. Kobach fixated on the fact that some hijackers had been living in the United States illegally.

What if they had been caught? “The 9/11 attack could have been stopped,” Kobach said.

While in Washington, he had connected with Hethmon — a very different man with the same goals. Hethmon, 58, is a former hippie who left the United States during the Vietnam War. He works for a group that opposes large-scale immigration: It believes that, given how much food, fuel and space the average American consumes, the environment can’t take many more people.

The two complemented each other. Kobach was astounded by Hethmon’s intricate knowledge of law and precedent. Hethmon was delighted to have an ally with political influence.

Mayor Barletta had called the right people. But he had the wrong law.

“We can definitely win in court,” Kobach told him. “But the ordinance is going to need to be redrafted.”

It needed the magic words. Illegal immigration is generally a federal matter, so the mayor didn’t have the power to go hunting for people without papers. But there was a loophole: The law allows towns to control “licensing” matters.

So Hazleton eventually decreed that everybody in town needed a license to rent an apartment. Using these licenses, the city could find illegal immigrants — and order landlords to evict them.

This was a lesson: It wasn’t necessary to catch illegal immigrants. It was necessary only to make them uncomfortable.

“What are you going to say to the people who say that you’re creating a climate of fear?” Hethmon recalled someone asking him recently. “I say: ‘Well, yeah, it’s not great. But it’s the best choice.’ ”

It grew from there. Hethmon helped write an ordinance that passed in Prince William County in 2007. The two of them helped write legislation that made it harder to hire illegal immigrants; Alabama said businesses could lose their licenses.

And they helped with laws on police powers, such as one in Arizona that requires officers to check immigration status during any lawful stop if they have reasonable suspicion that the person is in the United States illegally.

These laws redrew the map of an underground nation, turning some places into avoided zones. The University of Virginia found that more than 2,000 illegal immigrants left Prince William County. In Georgia, which passed a tough measure last May, migrant farm labor dropped by 30 to 40 percent. The workers skipped Georgia in their usual East Coast swing, and agriculture officials said $140 million was lost as fruit rotted in fields.

In Arizona, Hethmon and Kobach became involved after GOP state Sen. Russell Pearce wrote the first draft of a bill — offering small revisions and in some cases rewriting whole sections — during a series of phone calls and e-mails. They stressed that it was Pearce who provided the bill’s direction. Their job was to show him a legal way to do it.

Immigrant groups said the laws created the danger of police misconduct and racial profiling. In many places, however, politicians saw the results they wanted. Barletta became a congressman. Kobach was elected as a Republican to be Kansas’s secretary of state.

“People’s neighborhoods have gotten better, and the improvement in the neighborhoods has been most dramatic in the parts of the county that have heavier concentrations of minorities,” said Republican Corey Stewart, a champion of the Prince William law who chairs the county’s Board of Supervisors and wants to be lieutenant governor. The Virginia study found that that most crime statistics were unchanged but that the county’s hit-and-run accidents were reduced by nearly half.

But in court, the duo’s magic words began to fail them.

“We conclude that the ordinance’s sole purpose is not to regulate housing but to exclude undocumented aliens,” wrote Thomas M. Reavley, a federal appellate judge, in blocking a 2008 license-to-rent law in Farmers Branch, Tex. “It is an impermissible regulation of regulation.”

The duo has won some legal victories: The Supreme Court last year upheld an Arizona law that limits the employment of illegal immigrants. But judges have blocked all or parts of immigration laws in Alabama, Arizona, Georgia, Indiana, South Carolina and Utah, as well as in several cities.

In Farmers Branch, it has cost about $4.5 million to defend the law. And it hasn’t been in force for a day.

“How do you get out of those things? You know, if we just walk away from it, we’ve got the other people’s legal fees that would fall on top,” said Mayor Bill Glancy, who notes that the suspended law still seems to have driven away illegal residents, reducing turnover in schools. “You run legal expenses way up, to where it’s almost impossible to back down from it.”

Now, it all hangs on the Supreme Court. After Wednesday’s oral arguments, it could take weeks for the justices to decide whether Arizona’s broader immigration law is an unlawful overstep onto federal turf.

If they win, “copycat legislation will explode,” Hethmon said. “This is the classic environment for, if you will, sort of nativist-type sentiment. . . . It should explode at the states or — even better — [Congress] will be provoked to take action.”

In the meantime, Hethmon had an up-close and unpleasant experience with the same kind of local police he had done so much to empower.

The problem began with graffiti on a highway overpass in Bowie. Police there suspected that Hethmon’s teenage son might be involved and obtained a search warrant. They arrived at 7 a.m. on March 9 with a heavily armed team of county officers.

“Come in with masks, guns, screaming. You know, knocking everybody down,” Hethmon recalled. “I tried to explain to them, you know: ‘Look, I’m a lawyer, this is outrageous.’ [The reply was:] ‘Shut up and lie down on the floor.’ ”

Police said they found 2.5 grams of marijuana in the house. They filed charges against Hethmon, his son and his wife — all for the same drugs. The charges against Hethmon will be dropped, prosecutors said last week.

Hethmon said the experience has not changed his work.

“The fact that a law is legitimate and serving a purpose doesn’t mean that it can’t be abused,” he said. “Human beings are flawed people.”

And so, for the lesser-known of this duo, there has been a personal test. After he did so much to place greater trust in local police officers nationwide, police in Prince George’s County sent a SWAT team to his house to look for . . . spray paint.

“It’s ironic, you know,” Hethmon said.

Staff researcher Lucy Shackelford contributed to this report.