The government coalition, made up of the Social Democrats and the Greens, had agreed in October 2014 to freeze nuclear energy development, while the opposition has been in favour of building new reactors.
The deal is aimed at securing long-term energy supplies to households and industry, the government said.
Sweden has for years struggled to find viable alternative energy sources to replace its nuclear power, with renewable energies not yet able to fully meet the country's needs.
“Sweden shall have a robust electricity system with a high level of secure supply, low environmental impact and energy at competitive prices,” the agreement said.
Friday's deal paves the way for the construction of new reactors to replace the country's ageing ones at the end of their lifespans.
“We have, in this way, ensured that Sweden will have nuclear power for the foreseeable future,” a spokesperson for the conservative Moderate Party, Lars Hjälmered, told reporters.
Sweden has already shut down three of its reactors. It currently has nine functional reactors at three nuclear power plants, which generated 38 percent of the electricity used in the country in 2014.
The reactors were opened in the 1970s and 1980s. Most of them have lifespans of around 40 years and are in need of modernisation.
One reactor at the Oskarshamn plant in south-eastern Sweden is due to be decommissioned between 2017 and 2019. Two others, at the Ringhals plant in the south-west, are due to be decommissioned in 2018 and 2020.
“Permission may be granted to successively replace existing reactors as they reach the end of their economic lifespans,” the agreement said.
Friday's agreement also set a target of 100 percent renewable energy by 2040, and called for investments in solar, wind, hydro and bioenergy.
Energy Minister Ibrahim Baylan admitted nuclear power was not a renewable energy.
“This is of course a compromise,” he said.
An energy tax paid by producers will be abolished in 2019. The tax accounts for about 30 percent of the operating cost of a reactor, and has brought in about 4.5 billion kronor ($545 million) in gross revenue to government coffers annually.
Five of the eight parties represented in parliament signed on to the agreement, while the Left, the Liberals and the far-right Sweden Democrats refused.
Environmental group Greenpeace expressed disappointment at the deal.
“The energy agreement is planting small seeds for a renewable future. At the same time, they are spraying the energy industry with 4.5 billion kronor in tax cuts for nuclear power every year,” Greenpeace Sweden head Annica Jacobsson said in a statement.
“It's a compromise that means that Swedish energy policy risks standing still while large parts of the world undergo an energy revolution,” she said.