His district was “beginning to see early in his term a substantial influx from people outside who looked different,” said Mark J. Rozell, the dean of the Schar School of Policy and Government at George Mason University in Virginia. “So there was some populist appeal to his taking a very hard immigration stance.

“But,” Mr. Rozell added, “with Cuccinelli, for good or bad, it has always seemed that his positions came out of a certain core of his convictions.”

Mr. Cuccinelli’s allies say his positions are rooted in the belief that a legal immigration system is crucial to maintaining a functioning society. But Mr. Cuccinelli tends to tailor his views based on whether the legal immigrants in question are fleeing desperation south of the border or, like his ancestors, escaping Europe.

When a photograph of a drowned migrant father and daughter on the banks of the Rio Grande went viral in June, Mr. Cuccinelli said the father was to blame. When he was pressed on CNN about his edit of the Statue of Liberty poem, he said Emma Lazarus’s famous verses referred to “people coming from Europe where they had class-based societies.”

Mr. Cuccinelli did not respond to requests to be interviewed, but a Citizenship and Immigration Services spokeswoman, Jessica Collins, said Mr. Cuccinelli viewed the United States as a nation of immigrants; maintaining that tradition “requires immigrants to come here legally.” Ms. Collins said one of the first bills Mr. Cuccinelli passed as a state senator extended legal protections to immigrants in the country legally and illegally who had their personal documents withheld from them by the authorities.

But current and former Virginia lawmakers pointed to actions of a different type taken by Mr. Cuccinelli, such as a 2010 legal opinion that allowed Virginia law enforcement officials to check the immigration status of anyone they stopped. When Mr. Cuccinelli called into a radio station in 2012 to criticize a local ordinance that he said protected rats from being killed in Washington, he segued into immigration enforcement.