Whatever one feels about President Donald Trump’s temporary refugee ban – and I personally hope the President will quickly complete his vetting review and begin admitting refugees again so as to save lives – the hypocrisy of his critics is startling. None more so than President Obama himself.

The Syrian refugee crisis did not begin under Donald Trump, who is in office for 10 days. Rather, it came about through the callous and indifferent foreign policy of Barack Obama who refused to intervene in Syria, even as the slaughter there turned to genocide. Sunni Muslims, including children in Damascus and Aleppo, were being slaughtered by Shia militias, and Assad’s Alawite government, with the active support of Hezbollah and Iran. Obama did nothing.

But on Monday, President Obama suddenly came out, from his post-presidency vacation in Palm Springs, against the Trump administration’s executive order. Remember: Obama didn’t even lift a finger to save the children of Syria after Assad violated Obama’s self-declared red-line and gassed Arab children.

The immigrant crisis, which is absolutely tragic, resulted in large part from American inaction and Obama’s retreat in the Middle East. There might never have been an immigrant crisis if Obama would have instituted a no-fly zone, safe zones, or supported moderate Syrian rebels against Assad from the outset.

Countless people called on President Obama to pursue policies that would rescue the innocent people of Syria. He steadfastly refused. The result was not only the murder of 500,000 Arab men, women, and children, but the displacement of millions of refugees, which is the crisis we now face.

There can be no question that America must take in immigrants. We are a nation of immigrants. But these people should have never been forced to flee their homes in the first instance. The West should have stopped Assad from butchering his people at the source. Obama should have led the charge.

Now we have this crisis, and America must accept the refugees it can while still vetting immigrants to make sure American citizens are safe. President Trump is having to address a vast humanitarian crisis created by Obama’s inaction.

I understand President Trump’s need to protect Americans. It is the primary duty of a president. And I understand his need to revamp the vetting process. But I believe that President Trump could also have announced, as he proclaimed his temporary ban, that it did not apply to those brave souls who worked with American forces in Iraq.

He could also have announced it did not apply to those who have already obtained a green card and had been properly vetted. The failure to do so left a few hundred people stranded en route, and the mass outcry of those legitimately concerned with the undermining of American values.

There is more.

The president could have announced, at the same time as the ban, the establishment of safe zones, primarily in Syria, where people facing brutality could be protected. This way the President could have protected these immigrants at their origin.

Trump could perhaps have reached out to Russian President Vladimir Putin to pressure Assad to create safe areas that are not bombed. Trump could have told Putin that the creation of these safe zones is essential if the two of them are to have a relationship. Even now, Turkey administers some of the safe zones in the area, so we know it’s possible.

For now, let us conclude with three unassailable premises.

America welcomes refugees and is a nation of immigrants. Islam, while not inherently a militant faith, is producing a disproportionately high number of the world’s terrorists. The first responsibility of an American president is to protect the American people.

How can these three premises co-exist?

America should absolutely welcome refugees. But the president also has to protect the American people, and many immigrants, both in Europe and the United States, have taken advantage of the openness of our democracies to murder innocent people.

As well, the seven countries that are part of the new travel restrictions, along with other Muslim-majority nations, have a responsibility to fight extremists within their borders so they do not grow like a cancer, overrunning their own societies and exporting jihad.

Iran, for example, is one of the “banned” countries. In that, President Trump’s executive order follows in the footsteps of Jimmy Carter’s own ban of Iranians in April, 1980. But then Iran is also the world’s foremost state sponsor of terror.

The solution, therefore, is for “extreme vetting” to be implemented in an age of widespread Islamic terrorism, for America to allow in those who have been thoroughly vetted, alongside the President’s strong commitment to saving innocent Arab lives in Syria and Yemen by establishing safe areas where refugees can find immediate sanctuary.

The Jewish community should be at the forefront of calling on the President to safeguard the lives of refugees even as he legitimately acts to protect the American people against possible infiltration by terrorist elements.

But the rank hypocrisy of those like President Obama who are now cheering on the national demonstrations against an immigrant ban, when he chose to utterly ignore the Middle Eastern genocides of Yazidis, Christians, and Sunni Muslims in Syria, is shameful and perpetuates a legacy of indifference.

Both political parties must commit themselves to a program of welcoming the persecuted — and, even more importantly, protecting them at their source.

Shmuley Boteach, “America’s Rabbi,” whom the Washington Post calls “the most famous Rabbi in America,” has just published The Israel Warrior: Standing Up for the Jewish State from Campus to Street Corner. Follow him on Twitter @RabbiShmuley.