A former Facebook executive has quit his job and now lives as a recluse in the wilderness — because he is convinced that machines will take over the world.

Antonio Garcia Martinez worked as a project manager for the social media giant in Silicon Valley but became terrified by the relentless march of technology.

He reckons that machines will have taken half of humanity’s jobs within 30 years, sparking revolt and armed conflict.

So he quit his job, fled his home and now lives in woodland north of Seattle with a gun for protection.

He spoke to new two-part BBC2 documentary “Secrets of Silicon Valley,” which explores the growing influence of the tech hub on global development.

Martinez said: “If the world really does end, there aren’t going to be many places to run.

“Within 30 years, half of humanity won’t have a job. It could get ugly. There could be a revolution.

“I’ve seen what the world will look like in five to 10 years.

“You may not believe it but it’s coming, and it’s coming in the form of a self-driving truck that’s going to run you over.

“There are 300 million guns in this country, one for every man, woman and child, and they’re mostly in the hands of those who are getting economically displaced. There could be a revolt.

“You don’t realize it but we’re in a race between technology and politics, and technologists are winning. They’re way ahead.

“They will destroy jobs and disrupt economies before we even react to them and we really should be thinking about that.”

He said other ex-Silicon Valley employees had also resigned and were living on land isolated from society because they were equally frightened of what the future held.

Program host Jamie Bartlett, director of the Center for the Analysis of Social Media, said: “The tech gods are selling us all a better future but Silicon Valley’s promise to build a better world relies on tearing up the world as it is. They call it ‘disruption.’

“The mantra of Silicon Valley is that disruption is always good, and through smartphones and digital technology we can create more efficient, more convenient, faster services and everyone wins from that.

“But behind that beautifully designed app or that slick platform there’s a quite brutal form of capitalism unfolding and it’s leaving some of the poorest people in society behind.

“There’s a risk Silicon Valley’s promise to build a better world could inflict a nightmare future on millions of us.

“The big secret in Silicon Valley is that the next wave of disruption could tear apart the way capitalism works, and as a result the way we live our lives could be utterly transformed. ”

Artificial intelligence pioneer Jeremy Howard said: “People aren’t scared enough.

“They’re saying ‘Don’t worry about it, there will always be more jobs.’

“And it’s founded on this purely historical thing of there has been a revolution before, it was called the Industrial Revolution, and after it there were still enough jobs, therefore this new, totally different, totally unrelated revolution will also have enough jobs.

“It’s a ludicrously short-sighted, meaningless argument which incredibly smart people are making.”

He said if society did nothing, a “tiny class of society” would own “all of the capital and all of the data and everybody else adds no economic value, is despised by the class that has things because they’re worthless” creating “massive social unrest.”