PORTSMOUTH, N.H. — While exploring a 2016 bid for the presidency with a visit to New Hampshire on Friday, Texas Gov. Rick Perry sought to tie the threat posed by the Islamic State militant group to the U.S. immigration crisis — suggesting that the “porous” southern border had made America vulnerable to Islamic State infiltration.

Perry noted that the terrorist threat of Islamic State was brought to New Hampshire’s doorstep this week with the release of a video showing the beheading of U.S. photojournalist James Foley, who was raised in nearby Rochester, N.H.

“They have told us that they are coming, and why should we not take them at their word?” Perry said of the Islamist militants as he addressed a business luncheon in Portsmouth.

“There already may be ISIS cells, ISIS individuals in America — we don’t know,” he continued, using an acronym for Islamic State. “They may have used our southern border, because we know it’s porous and we know we’re not doing our job. This country is not doing its job. The federal government is not doing its job to secure the border. And we know how to do it.”

Shawn Turner, a White House spokesman, said he was not “aware of any information or intelligence that would support these claims.” On CNN Friday morning, Rear Adm. John Kirby, a Pentagon spokesman, said there was no indication that Islamic State militants were coming across the border with Mexico.

Perry’s remarks in New Hampshire were in keeping with the hawkish tone of his speech Thursday at the conservative Heritage Foundation in Washington, where he called for “overwhelming force” to be used against Islamic State. Perry also had warned that the militant group could soon launch an attack on the United States.

He issued a similar warning Friday, but did not go quite as far as he did Thursday when he drew a direct link between illegal immigration and his concern about Islamic State by talking about the threat of a militant who “slips across our unsecure border.”

Speaking to reporters after Friday’s appearance, Perry acknowledged that there is no evidence to show that Islamic State militants have entered the U.S., but asked, “Why would you think that it was not certainly a possibility?

“I agree that there is no hard evidence, but do we need to wait?” he said. “Do we need to wait until there is an attack on America before we secure the border?”

Reflecting on his 2012 presidential run in New Hampshire, Perry said he didn’t stay long enough to know whether he was a good fit for the state. “I didn’t spend the time. I didn’t have the preparatory time,” he said.

“I learned some really, really good, humbling and frustrating lessons running for the presidency. One is that if you’re going to do this, you shouldn’t have major back surgery six weeks before you announce,” Perry said. “You’re probably not going to be physically or mentally on top of your game.”

Perry said his most important lesson, however, was the fact that being elected governor of Texas three times and serving in that role was not good enough preparation to run for the White House. This time, he is correcting that mistake, even though he has not made a final decision on whether to run.

“I just think you have to spend a lot of time in these states if you’re going to do it,” he said. “It’s like a relationship before you get married. … Generally there’s a courtship that goes on. There’s a period of time that you need to spend with people. They need to know you; you need to know them, and I didn’t do that.”

During the luncheon, an audience member asked Perry about his recent indictment on charges of abuse of power, which stemmed from his veto of funding for an anti-corruption unit after the attorney in charge of that office was arrested on a drunken driving charge.

He once again described the indictment as an attack on the U.S. system of government and vowed to fight the indictment with “every fiber” in his body.

“Hopefully it will be behind us quickly and we can get on about our business,” he said. “But even if it’s not, I’m going to do my job.”