In the vote by show of hands, only the right-wing Republicans party opposed, while left-wing lawmakers abstained.
No new permits will be granted to extract fossil fuels and no existing licences will be renewed beyond 2040, when all production in mainland France
and its overseas territories will stop.
Socialist lawmaker Delphine Batho said Tuesday she hoped the ban would be “contagious”, inspiring bigger producers to follow suit.
France extracts the equivalent of about 815,000 tonnes of oil per year — an amount produced in a few hours by Saudi Arabia.
But centrist President Emmanuel Macron has said he wants France to take the lead as a major world economy switching away from fossil fuels — and the nuclear industry — into renewable sources.
His government plans to stop the sale of diesel and petrol engine cars by 2040 as well.
Above all the ban will affect companies prospecting for oil in the French territory of Guyana in South America, while also banning the extraction of shale gas by any means — its extraction by fracking was banned in 2011.