BERLIN — The German government has decided to extend the life spans of the country’s 17 nuclear plants while alternative energy sources are developed, a move that is also likely to create windfalls for both power companies and strained government coffers.

The decision comes at a time when several European countries, including Italy and Sweden, are reconsidering long-held policies against nuclear power, not only to develop new sources of energy but also to combat climate change.

New taxes levied on utility companies as part of the deal will be used in part to help develop renewable energy sources, Chancellor Angela Merkel said Monday. But she said Germany could not afford to get rid of nuclear power as planned because the amount of renewable energy available would not be sufficient to fill the gap.

“Nuclear energy is a bridge,” she said.

Under a German law, passed by a previous government in 2002, the last nuclear power plant was to be shut by 2022. That decision, bitterly resented by the nuclear energy companies, was largely supported by the German public, which has a deep aversion to anything nuclear, a sentiment that intensified after the nuclear accident at Chernobyl.