The text approved on Friday does not outlaw conventional drilling for oil and gas, but leaves it up to state governments to decide on individual cases.
But fracking, or hydraulic fracturing, which is carried out by blasting a mixture of water, sand and chemicals underground to release shale oil and gas, will be banned.
Only a handful of projects for scientific or non-commercial purposes are likely to meet the conditions.
Fracking has been largely unregulated in Germany until now, and the current coalition government under Angela Merkel has been working for months to draw up the proposed rules.
The coalition had put forward a draft law on the issue in April 2015, but the text was mothballed due to strong divisions over the subject.
But the government has now revived the proposal at the last minute as companies, tired of waiting for a legal framework, last week said they would push ahead with their fracking projects that had been on hold for five years.
The German population harbours a deep suspicion towards fracking and fears its impact on the environment and, in particular, drinking water resources.
But the industry had run an intense campaign to at least keep the option open for such a technology to be used.
Fracking is banned in France, but popular in the United States, where it has helped to slash the country's energy bill substantially.
Gas producers like Wintershall or Exxon Mobil, had initially agreed to a five-year moratorium on their extraction projects, but ended up losing patience with German authorities.
The opposition Greens have accused the government of rushing through the vote, by using twin distractions – the British referendum on EU membership and the Euro 2016 European soccer championships – to ram through a text that it finds too lax.