Israel's Prime Minister Benjamin Netanyahu said on Tuesday that an electronic fence along the Israel-Egypt border has saved the Jewish state from jihadist attacks or what he believes would be worse -- a tide of African migrants, Daily Mail reported.

"Were it not for the fence, we would be faced with... severe attacks by Sinai terrorists, and something much worse, a flood of illegal migrants from Africa," Netanyahu's office quoted him as telling a development conference in the southern Israel desert town of Dimona.

The interior ministry says there are currently some 42,000 African migrants in Israel, mainly from Sudan and Eritrea, and the government has ordered that thousands of them must leave or face indefinite imprisonment.

They began slipping into Israel illegally in 2007 through what was then a porous border with Egypt's lawless Sinai region.

The frontier with Israel's Negev desert has since been given a 200-kilometre (124 mile) hi-tech fence and the influx has halted.

Netanyahu said a tide of non-Jewish immigration would threaten the very fabric of Israel.

"We are talking about a Jewish and democratic state, but how could we assure a Jewish and democratic state with 50,000 and then 100,000 and 150,000 migrants a year," Netanyahu said.

"After a million, 1.5 million, we might as well shut up shop," he added. "We did not close down, we built a fence."