Its government also agreed to cancel its latest licensing round on Thursday, which gives firms permission to search for and produce oil and gas.
"We are now putting a final end to the fossil era," said Denmark's climate minister.
Greenpeace Denmark described the announcement as a "watershed moment".
However, the country's latest licensing round was facing uncertainty, after Total of France pulled out in October, leaving only one other applicant.
Denmark is currently the largest oil producer in the European Union, although it produces much less than non-EU members Norway or the UK.
It pumped 103,000 barrels a day in 2019, according to analysis by UK oil giant BP
There are 55 drilling platforms on its territory, across 20 oil and gas fields.
"We're the European Union's biggest oil producer and this decision will therefore resonate around the world," Danish climate minister Dan Jorgensen said on Thursday.
The decision will cost Denmark about 13 billion kroner (£1.1bn), according estimates by the energy ministry, though it said this amount was subject to substantial uncertainty.
By Adrienne Murray, Denmark
This move marks a historic milestone. No other sizeable oil producer has taken such a step, Dan Jorgensen tells the BBC.
Denmark has been positioning itself as a frontrunner fighting climate change, but its oil production had presented a dilemma.
Since the 1970s, Denmark has earned billions of dollars from its North Sea oil. That's also helped finance the country's generous welfare state.
"We want to be climate neutral in 2050. And if we are to have any credibility in that, then this is a necessary decision," says Mr Jorgensen.
When the current government came to power, Prime Minister Mette Frederiksen called it "the first climate election".
But recently it has faced criticism for not taking more ambitious steps to reach its climate goal. This latest decision now sends a stronger message.
Economic factors have played a role. Lower oil prices and higher costs have seen interest wane in the latest round of oil bloc tenders.
Even so, about 4,000 jobs depend on the sector - mostly on Denmark's west coast.
As part of the new plan, Mr Jorgensen says carbon capture and storage technology will be developed in the area, and new job creation will come from the country's growing off-shore wind sector.
Denmark is regarded as having one of the world's most ambitious climate targets.
It aims to reduce greenhouse gas emissions from 1990 levels by 70% by 2030, as well as reach net zero emissions by 2050 - both targets which have been passed into law.
Helene Hagel, head of climate and environmental policy at Greenpeace Denmark, said that the new announcement meant "the country can assert itself as a green frontrunner and inspire other countries to end our dependence on climate-wrecking fossil fuels.
"This is a huge victory for the climate movement and all the people who have pushed for many years to make it happen."
Governments around the world have also committed to take further action on climate change as part of a wider plan to meet the goals of the Paris Agreement.
The UK will aim to cut its carbon emissions by at least 68% of what they were in 1990 by the end of 2030, Prime Minister Boris Johnson announced on Friday.
Scientists have said, however, that even if the UK and other nations keep their promises on cutting emissions there was no guarantee the world would avoid serious global warming.