Brexit could prove to be a mere bump on the road toward “human unification”, according to a new book by bestselling historian Yuval Noah Harari, which warns politicians against becoming distracted by the rise of nationalism in the world.

The Israeli academic, whose first book, Sapiens, became a surprise publishing sensation by charting the rise of the human species, turns his attention to current affairs for the first time with a swipe at what he argues is a short-sighted response to global challenges in countries such as the UK, US, Russia and Israel.

“Brexit may well initiate the simultaneous unravelling of both the UK and the EU. But in the long run, history’s direction is clear cut,” he writes. “In recent generations the few remaining civilisations have been blending into a single global civilisation.”

The new book, 21 lessons for the 21st Century, is published in August and comes amid a period of unprecedented introspection in British politics over how to leave the European Union. Yet Harari argues the coming challenges of global warming, technological disruption and nuclear proliferation will make us “ever more interdependent” and in need of cooperative projects such as the EU.

“In a different century and different situation, I don’t think there is anything necessarily wrong about Brexit,” he added in an interview. “If you want to be a completely independent country and not part of a bigger organisation, then fine. The problem is that given the kind of challenges we face today, the opportunity costs of being very self absorbed are becoming higher and higher all the time.”

The thesis may infuriate Brexit supporters who regard it as a way for Britain to look out to the world more, but Harari also has words of criticism for liberals who regard the EU referendum as a catastrophe.

“Like a person imagining that a bad headache signifies a terminal brain tumour, many liberals fear that Brexit and the rise of Donald Trump portend the end of human civilisation,” he writes. “The first step is to tone down the prophecies of gloom and switch from panic mode to bewilderment … more humble, and therefore more clear-sighted.”

He also claims it is not inevitable that humanity will learn to collaborate more, warning of a possible “unravelling” of the EU in the wake of Brexit – with worrying implications.

“If the European project fails … it would indicate that belief in the liberal values of freedom and tolerance is not enough to resolve the cultural conflicts of the world,” writes Harari. “If Greeks and Germans cannot agree on a common destiny, and if 500 million affluent Europeans cannot absorb a few million impoverished refugees, what chances do humans have of overcoming the far deeper conflicts that beset our global civilisation?”

“Let’s say the rise of artificial intelligence completely disrupts the global job market, this will create far far bigger social and economic challenges than the immigration of a few million people to the EU or some workers from Poland and Romania to the UK,” he added.

Harari, who lectures at the Hebrew University of Jerusalem, was also critical of Israeli nationalism in the wake of the killing of Palestinian protesters last week.

“If every nation thinks about itself, then who is thinking about the global problems?” he said. “I don’t see Israel making any significant contribution to confronting the main challenges of humankind.”

But the book singles out the EU as a model for how national interests can be balanced and what is at stake if it fails.

“After centuries of terrible bloodshed, French, Germans, Italians and Britons have finally built a mechanism that ensures continental harmony – only to have the British public throw a spanner into the miracle machine,” writes Harari.

“We have a global ecology, a global economy and a global science – but we are still stuck with only national politics,” he adds. “To have effective politics we must either deglobalise the ecology, the economy or the march of science – or we must globalise our politics.”