Philadelphia Mayor Michael A. Nutter scaled back cooperation with the Department of Homeland Security’s immigration- enforcement efforts in April 2014, accusing agents of aggressively targeting for deportation illegal immigrants who led otherwise law-abiding lives.

Then he got a visit from Homeland Security Secretary Jeh Johnson. And a follow-up phone call. And more calls from DHS officials. Their pitch: Support a new DHS program that aims to work with cities to deport immigrants who commit serious crimes and pose a national security threat — but take action against virtually no one else.

Nutter, who won plaudits from immigrant rights groups for his stand against the federal government, hasn’t agreed. He praised Johnson in a recent interview but said the city is “articulating areas of concern we have with regard to the new program.’’

His hesitance speaks to the promise — and the perils — of an intensive outreach effort being undertaken by Johnson, who runs the third-largest Cabinet department. The man charged with keeping the homeland safe is trying to repair DHS’s frayed relationship with cities and police departments, at a time of divisive national debate over the nation’s 11.3 million illegal immigrants.

The problems stem from a revolt against DHS’s enforcement of immigration laws. Johnson in November scrapped Secure Communities, a program under which DHS asked police to hold immigrants it wanted to deport for up to 48 hours after their scheduled release from custody. More than 350 communities had ended or dialed back their participation, citing legal and civil liberties concerns.

Now, DHS is encountering similar challenges as it rolls out the replacement for Secure Communities: the Priority Enforcement Program (PEP), which began July 2. Pro-immigrant groups are already blasting the program, under which DHS will still coordinate with police to deport illegal immigrants but will mostly seek to be notified before they are released from custody, rather than having immigrants held beyond their scheduled release.

“Secure Communities needed to be fixed because it was inhibiting our ability to get at the criminals,’’ Johnson recently told the House Judiciary Committee, adding that he thinks PEP “resolves the legal and political controversy.’’

‘Walking a fine line’

While DHS says more than 30 of the nation’s largest law enforcement agencies have indicated a willingness to work with the agency on PEP, few have publicly said they will participate. The city of Los Angeles told The Washington Post that its police department, the nation’s third largest, will not, though Los Angeles County is participating. Other jurisdictions — such as Philadelphia, with the fourth-largest police force — are wrestling with the issue at a time of changing demographics.

“We are walking a fine line,’’ said John H. Eaves, chairman of the Board of Commissioners in Fulton County, Ga., where Atlanta is located. The county is discussing PEP with U.S. Immigration and Customs Enforcement (ICE), the DHS agency enforcing the program.

“We want to make sure our community is safe,’’ Eaves said. “At the same time, we are a diverse community with a strong immigrant population, and we want to make sure that everyone is afforded civil and human rights, and that no one is unduly held beyond a certain period of time.’’

The debate reflects growing tension over immigration, which has become a major issue in the 2016 presidential campaign, in part because of Republican candidate Donald Trump’s disparaging remarks about illegal immigrants. The debate was inflamed by the July 1 killing of Kathryn Steinle along the San Francisco waterfront, allegedly by an illegal immigrant with a long criminal record.

The House recently voted to strip some federal funds from cities that do not cooperate fully with federal immigration authorities. They are known as sanctuary cities, but there is no reliable number of such cities or consensus on what constitutes a sanctuary city. The debate over PEP, experts said, is more reflective of the tensions between DHS and police over undocumented immigrants taken into custody.

DHS officials expressed confidence that localities will embrace PEP, saying the program is needed to deport dangerous criminals and that it resolves the constitutional and other questions surrounding Secure Communities. But they acknowledged that their outreach effort has been difficult.

“A large part of the skepticism comes from just a poor track record with Secure Communities,’’ said one DHS official, who spoke on the condition of anonymity to discuss private meetings with local officials about PEP. “There’s a trust deficit here that has to be overcome.’’

Some immigrant advocates said Johnson — who along with DHS Deputy Secretary Alejandro Mayorkas has met with or spoken to hundreds of local officials about PEP — deserves credit for admitting that Secure Communities wasn’t working and for starting over.

“When has an administration just turned its back on and scrapped an entire program that it spent five years expanding and rolling out nationwide?’’ said Marshall Fitz, managing director for immigration at Emerson Collective, which advocates immigration reform. “Secretary Johnson really did take to heart a lot of the concerns that were raised.’’

But Angie Junck, supervising attorney at the San Francisco-based Immigrant Legal Resource Center, criticized PEP as “the reincarnation of the failed and dangerous Secure Communities program.’’

“We see this as DHS kind of rebranding to rebuild the trust they lost with a lot of local law enforcement agencies,’’ she said. “We are very concerned that it will repeat the mistakes of the past.’’

Legal trouble

Secure Communities began during the George W. Bush administration and was expanded under President Obama. It allowed ICE to lodge official requests with police departments that had arrested someone ICE wanted to deport. The requests called on police to hold the immigrants for up to 48 hours after their scheduled release so ICE could pick them up.

Although the program had been billed as a crackdown on immigrants who had committed serious crimes, it scooped up some long-term illegal immigrants with families and community ties who were arrested for minor offenses and then deported.

As outcry grew, Secure Communities ran into legal trouble. A series of federal court decisions raised legal and constitutional questions about the ICE hold requests, known as detainers, including a ruling last year in Oregon that said police could be liable for holding immigrants beyond their scheduled release date.

With police and sheriffs departments backing away, Johnson in November replaced Secure Communities with PEP. It limited the use of detainers and shifted the emphasis to notification requests, under which ICE will ask to be notified 48 hours before an immigrant is released from custody. In another key change, ICE will file the requests in cases where the immigrant has been convicted of a crime; before, the requests included those only charged.

The new program is part of a broader shift in DHS’s priorities in which the department has been narrowing enforcement efforts to three groups of illegal migrants: convicted criminals, terrorism threats or those who recently crossed the southwest border.

But pro-immigrant groups are questioning PEP, saying it will further undermine police efforts to gain trust from immigrant communities. Others are raising new legal concerns, especially about the continuing use of detainers. Partly in response to the court decisions, ICE added boxes to its detainer form, in which agents will indicate their “probable cause” for why the immigrant in police custody can be deported.

“Probable cause is not a series of checked boxes,’’ said Kate Desormeau, a staff attorney for the ACLU Immigrants’ Rights Project, who said ICE should get approval from a judge before taking custody of an immigrant. She said the ACLU is considering whether to bring legal action over PEP.

Johnson has been selling the new program for months and won support from Montgomery County, Md., Police Chief J. Thomas Manger, president of an association of major-city chiefs. “DHS and ICE heard the concerns and complaints from police around the country,’’ he said.

The District, which scaled back its cooperation with ICE several years ago, has not said publicly whether it will participate in PEP.

Other large-city police chiefs and officials praised Johnson’s outreach, including Nutter, the Philadelphia mayor. “I trust Secretary Johnson. He has been tremendously sensitive and focused on these issues,’’ Nutter said, before adding that he has reached no decision about whether to participate in PEP.

In Cook County, Ill., which has also limited its cooperation with ICE, Board of Commissioners President Toni Preckwinkle said in a statement that she “greatly appreciates Secretary Johnson traveling to Chicago’’ to meet with her about PEP.

But she has also not committed, saying the county “is open to continued dialogue and further meetings.’’

Meanwhile, officials in New York City, which has the nation’s largest police department, said only that they are still in talks with DHS. But the city’s policy severely limits its cooperation with ICE detainers, saying they must be accompanied by a federal warrant.

“Families will no longer be needlessly torn apart by ICE’s dragnet enforcement efforts,” New York City Council Speaker Melissa Mark-Viverito said before the policy was approved in October.

It took effect six days before DHS announced the PEP program.