On his way to planting an explosive in a Manhattan alley last September, suspected bombmaker Ahmad Rahimi stumbled into a deep hole in the U.S. system of safeguards against domestic terrorist attacks.

The Elizabeth, N.J., resident had twice come under scrutiny by the FBI because of reported extremist views and suspicious travel overseas. But investigators found no grounds for arresting him, and they lacked alternative measures for maintaining surveillance or influencing the ­Afghan immigrant’s behavior.

That gap is the subject of a new bipartisan report that warns of a serious flaw in U.S. defenses against homegrown terrorism: the lack of an effective, comprehensive system for finding, redirecting and rehabilitating Americans who may be on a path to violent extremism. Unless such a system is put in place, the report says, law enforcement officials will be left to try to prevent attacks only after the would-be terrorist becomes operational.

“Fighting terrorism requires both tactical efforts to thwart attacks and strategic efforts to counter the extremist radicalization that fuels its hatred and violence and undergirds its strategy and global appeal,” says the report, based on a year-long study commissioned by the Washington Institute for Near East Policy think tank.

[U.S. team uses Facebook to peel off potential terrorist recruits]

The report, released Wednesday, urges federal backing for an array of programs that would seek to prevent radicalization from taking root in local communities, as well as measures to identify and help people already on a path toward radicalism. The proposed remedies would mostly take place outside the criminal justice system while maintaining a strong “connective tissue” with law enforcement so that police can be forewarned if someone appears on the brink of committing violence, it says.

The study’s release comes as the Trump administration is conducting a formal review of federal programs that focus on countering violent extremism — or CVE, as the field is known. Current efforts have drawn criticism from lawmakers as well as some senior Trump aides.

Matthew Levitt, a former FBI counterterrorism analyst and a co-author of the study, said past U.S. administrations have been slow to embrace community-based approaches that some politicians see as “soft.” The resulting absence of comprehensive strategy has allowed dangerous people to slip under the radar screen, he said.

Such was the case with the suspects in two of last year’s most sensational acts of domestic terrorism: Rahimi, the man suspected of planting homemade bombs in New York’s Chelsea neighborhood and two New Jersey towns, and Omar Mateen, the gunman who killed 49 people in a nightclub in Orlando in June. Both men had been subjects of FBI probes in previous months, but investigators dropped the cases after failing to find evidence of criminal intent.

[Jihadist groups hail travel ban as a victory]

“Empowering and incentivizing communities to be active in these cases is in the local and national interest, and the FBI would be the first to say this,” said Levitt, who now directs the Washington Institute’s Stein Program on Counterterrorism and Intelligence. At a time when the bureau is conducting more than 900 ­terrorism-related investigations around the country, he said, it is vital that community organizations be involved in “reducing the pool of future violent extremists and handling cases in which the person has not yet crossed the legal threshold.”

The study, which included high-ranking counterterrorism officials from previous Republican and Democratic administrations, recommends that government agencies adopt approaches similar to those used by public-health officials to prevent and contain epidemics. It calls for a three-tiered system that would seek to limit exposure to extremist ideology in the first place, then spot potential problems and respond to them before they turn into serious threats. The approach would draw on community organizations, including mosques, churches, civic organizations, social workers and mental health counselors.

The system’s latter tier would include “off-ramp” programs to help rehabilitate formerly radicalized people — including former prison inmates and defectors or returnees who traveled overseas to join jihadist groups. The U.S. penal system now offers scant assistance to ensure that people convicted of terrorism-related offenses do not return to their old patterns, Levitt said.

[Use of terrorist drones by ISIS spurs terrorism fears]

“In the next few years, you’re going to see people released from prison after being convicted on terrorism charges,” he said. “There are no reentry programs within the U.S. prison system other than the typical parole officer, who doesn’t do CVE stuff.”

The report recommends that the proposed initiatives address not just Islamist radicalization but also other extremist groups, including far-right white supremacists behind a rash of attacks on ethnic and religious minorities in recent months. It also suggests that U.S. officials exercise caution in choosing terms used to label or describe radical groups.

The bipartisan panel noted the distinction between “Islamic” extremism — the administration’s preferred term — and “Islamist” radicals, which refers to followers of a “radical political ideology separate from Islam as a religion.”

“Any serious and effective effort to counter the extremist ideology driving groups like the Islamic State and al-Qaeda must be part of a larger strategy to prevent and counter the full range of Islamist and other extremist ideologies posing security threats to the United States,” the report says. “And the reason is not ideological; it is practical and programmatic and has to do with how good-governance and public safety programs actually work on the ground in local communities across the country.”