Can President Donald Trump and the Republican-majority Congress make a deal? That’s a question raised by the announcement that the Trump administration will end the Deferred Action for Childhood Arrivals program in six months.

DACA, put in place by the Obama administration, provided protection from deportation to immigrants who entered the United States illegally as children and who didn’t have serious criminal records and were working or in school or the military.

Trump is on strong legal ground. Barack Obama established DACA in 2012, even though, as he had earlier explained, the Constitution gives Congress, not the president, the authority to set policy on immigration and naturalization.

Moreover, Obama’s 2014 Deferred Action for Parents of Americans, which would have given protection to some 4 million parents of legal residents, was ruled invalid by federal courts. Ten state attorneys general have been threatening to challenge DACA on identical grounds.

Attorney General Jeff Sessions is thus right when he says that DACA could be overturned by the courts, leaving the 800,000 young people currently covered with no protection. They may be better off with Trump’s order leaving DACA in place for six months than they would be then.

Though DACA is, as Democratic Sen. Dianne Feinstein agreed, “on shaky legal ground,” the political case for the policy is strong. Polls show large majorities in favor because they agree with what Trump said in his written statement: “I do not favor punishing children, most of whom are now adults, for the actions of their parents.”

Trump has made clear that he would support a legislative version of DACA — and it could get majority support in both houses of Congress. But because some Republicans, such as Rep. Steve King, are opposed, any bill must be a bipartisan compromise. That means that Democrats will have to make concessions to get the issue on the congressional calendar.

The late Sen. Edward Kennedy was particularly expert in fashioning bipartisan compromises. He would accept provisions he didn’t like in return for others he favored and thought more important. He would oppose as “poison pills” amendments he personally supported but believed would cost a bill needed Republican votes. One such poison pill did pass, with the help of the vote of then-Sen. Obama, and torpedoed the 2007 comprehensive immigration bill, which would have been signed by Bush.

Ten years later, the facts and opinion on immigration have changed. One possible path forward was suggested by Sen. Tom Cotton, co-sponsor of a different comprehensive immigration bill supported by Trump. Giving young people who violated the law — even if it was through no fault of their own — legal status would have “negative consequences,” Cotton argues, opening up chain migration of low-skilled collateral relatives and incentivizing others to bring children in illegally. So a bill to replace DACA, he says, should be accompanied with limits on extended family unification migration and with “enhanced enforcement measures,” such as mandatory E-Verify.

Such provisions will most likely be opposed by the lobbies whose ultimate goal has been giving legal status to almost all of the 11 million immigrants here illegally, a measure that was part of the 2007 and 2013 comprehensive bills. But Democrats may have to accept them to help the dreamers.

Much will depend on the deal-making skill of the president and congressional leaders. Will they measure up to the standard set by Ted Kennedy?