The father of Ahmad Rahami, the Afghan-born man arrested after bombings in New York and New Jersey, says he reported concerns about his son to the FBI in 2014. (Reuters)

The man accused of a bombing spree in New York and New Jersey was flagged by Customs and Border Protection officials for questioning at least twice over the last few years after returning from Pakistan, but in both cases they found no reason to deny him entry to the United States, law enforcement officials said.

Ahmad Khan Rahami, who remains heavily sedated in a New Jersey hospital after a police shootout that resulted in his arrest on Monday, was one of thousands of such individuals traveling from high-risk countries who are flagged each year for “secondary” questioning at the airport.

He was in Pakistan in 2013 and in 2014, including stays in Quetta, a stronghold of militant groups, law enforcement officials said. And in both cases, upon his return, “nothing derogatory” arose out of the screenings, and the information was relayed to the FBI, said one senior law enforcement official, who spoke on condition of anonymity because the investigation is ongoing. “There was no suggestion of wrongdoing or anything of concern.”

Federal prosecutors this week charged Rahami with nine counts-–including using weapons of mass destruction and bombing a public place. He was flagged by CBP’s National Targeting Center even before he stepped on a flight, said a second senior law enforcement official.

“They look at millions of records a year and they determine based upon their targeting rules who gets asked for more information or pulled over,” said the second official. For people flying from high-risk countries, they would check where and how a passenger bought his ticket, for example.

Rahami, a naturalized U.S. citizen born in Afghanistan, was tagged as a military-age male returning from Pakistan, the official said. But that alone did not disqualify him from entry.

“The idea that we’re going to stop every military age male who’s gone to Pakistan” is not feasible, he said.

Customs officers would also have looked at his belongings, including his cellphone. If his phone contained pictures of, say, a terrorist training camp, that would likely have been cause to detain him for further questioning. Even his stays in Quetta would not be enough on their own to deny him entry, absent any “definitive derog” or derogatory information, officials said.

“This is all risk-based modeling, and questioning by professionals, and you make your best judgment based on the information that you have,” the second official said.

“We don’t have any ‘pre-watchlist,’” he said. “Otherwise we’d be so gummed up with a backlog of reviews, it would be impossible to do our job.”

In August 2014, the FBI received a report through a New Jersey intelligence-sharing center that Rahami’s father was concerned his son was interacting with dangerous people. The FBI’s Newark Field Office looked into that report, interviewing the father and running Rahami’s name through databases. CBP’s secondary screening showed up, including the information about his sojourns in Quetta. But nothing sufficient emerged to justify opening a preliminary investigation, officials said.

At the time, Rahami himself was not questioned as he was in jail after a domestic assault, officials said.

What would have got the FBI’s attention then is any sign that Rahami was influenced or inspired by a foreign terrorist organization.

When Rahami was arrested Monday, investigators recovered a blood-stained journal that contained an eclectic mix of terrorist inspirations, including Al-Qaeda and the Islamic State.

In the journal, which Rahami had with him during his shootout with police, the 28-year-old wrote about al-Qaeda leader Osama bin Laden, radical American preacher Anwar al-Awlaki and Islamic State Spokesman Abu Mohammad al-Adnani, authorities said. He also alluded to the Boston Marathon bombings and the 2009 Fort Hood shooting in Texas, authorities said.

If Rahami had had something like that journal on him when he re-entered the country in 2014, that “probably would have led to him being interviewed by the FBI,” the second official said.

(Screenshot via the House Homeland Security Committee)

In the journal, Rahami appears to reference guidance from Adnani to “clearly attack the kuffar in their backyard.” Kuffar is an Arabic term for nonbelievers.

Rahami is accused of planting several bombs — first in Seaside Park, N.J., along a scheduled race route, in a dumpster and along the street in New York’s Chelsea neighborhood, and finally at a train station in Elizabeth, N.J.

Thirty-one people were hurt in the Chelsea blast; no one was injured in the others.

U.S. Attorney Preet Bharara said that the first case to proceed would be the one in Manhattan, and prosecutors there had filed a writ with the U.S. Marshals service in hopes to bring Rahami to court soon. If convicted, Rahami could face up to life in prison.

Investigators, meanwhile, continued to probe how Rahami carried out the attacks, whether he acted alone and what direction or inspiration he might have drawn from trips overseas.

Rahami traveled to Afghanistan and Pakistan between 2011 and 2014, including a stay in Quetta, a stronghold of militant groups.

In 2014, the FBI conducted an “assessment” on Rahami– a very low-level probe in response to a tip to determine whether there is cause to open a preliminary investigation.

Those trips would have surfaced in the assessment, which included checks of internal databases, officials said. But travel alone to a country that harbors members of al Qaeda or the Taliban would not be enough to open an investigation, particularly if the person was from that country.

Nothing about Rahami at that time “suggested that he had ties to terrorism to justify” opening a preliminary investigation, said a senior law enforcement official, who spoke on condition of anonymity because the probe is ongoing.

Law enforcement officials said on July 7 Rahami bought the Glock 9 mm handgun that he used to shoot two Linden, N.J., police officers trying to take him into custody from a gun dealer in Salem, Va., in July. To buy a handgun in Virginia, one must be a resident of the state, but one official said Rahami was able to legally purchase the gun in Salem because he presented a valid Virginia state ID with an address in Roanoke. He also passed a federal background check, officials said.

The officials would not reveal the name of the gun store. One said Rahami had relatives in the area, two of whom were taken into custody in a vehicle Sunday night and let go amid law enforcement’s furious manhunt.

New York Police and FBI officials said Wednesday afternoon that they also were seeking two men who were caught on surveillance footage encountering a bomb on the street that did not detonate in Manhattan on Saturday night. Police have said the men took the bomb out of the suitcase, then walked away with the luggage.

James R. Waters, the New York Police Department’s chief of counterterrorism, said investigators had “no reason to believe that they’re connected” to the bombings, but detectives were hoping to talk to them and recover the suitcase. He noted the men were “very, very lucky” to have avoided injury themselves, given what they handled “was a very shock sensitive device.”

A combination of luck, and Rahami’s own ineptitude, likely stemmed the damage from the attacks, officials said. In the criminal complaint against Rahami, officials said he and his car were caught on surveillance cameras, and he left a host of fingerprints on the materials recovered by authorities. The complaint said that Rahami had purchased numerous items for the explosives — including igniters, circuit boards and citric acid — on eBay and had them shipped to his workplace. Investigators also found that a social media account used by Rahami had liked videos relating to jihad.

“He wasn’t really quite sure what he was doing,” said Gregory Shaffer, a former FBI agent who has worked extensively on national security issues. “He’s a wannabe. A lot of these terrorists are that way.”

Nakashima reported from New York. Julie Tate contributed to this report.