BERLIN - German lawmakers have finalized the country's long-awaited phase-out of coal as an energy source, backing a plan that environmental groups say isn't ambitious enough and free marketeers criticize as a waste of taxpayers' money.

Bills approved by both houses of parliament Friday envision shutting down the last coal-fired power plant by 2038 and spending some 40 billion euros ($45 billion) to help affected regions cope with the transition.

The plan is part of Germany's `energy transition' - an effort to wean Europe's biggest economy off planet-warming fossil fuels and generate all of the country's considerable energy needs from renewable sources. Achieving that goal is made harder than in comparable countries such as France and Britain because of Germany's existing commitment to also phase out nuclear power by the end of 2022.

“The days of coal are numbered in Germany,” Environment Minister Svenja Schulze said. “Germany is the first industrialized country that leaves behind both nuclear energy and coal.”

Greenpeace and other environmental groups have staged vocal protests against the plan, including by dropping a banner down the front of the Reichstag building Friday. They argue that the government's road map won't reduce Germany's greenhouse gas emissions fast enough to meet the targets set out in the Paris climate accord.

“Germany, the country that burns the greatest amount of lignite coal worldwide, will burden the next generation with 18 more years of carbon dioxide,” Greenpeace Germany's executive director Martin Kaiser told The Associated Press.

Kaiser, who was part of a government-appointed expert commission, accused Chancellor Angela Merkel of making a “historic mistake,” saying an end date for coal of 2030 would have sent a strong signal for European and global climate policy. Merkel has said she wants Europe to be the first continent to end its greenhouse gas emissions, by 2050.

Germany closed its last black coal mine in 2018, but it continues to import the fuel and extract its own reserves of lignite, a brownish coal that is abundant in the west and east of the country. Officials warn that the loss of mining jobs could hurt those economically fragile regions, though efforts are already under way to turn the vast lignite mines into nature reserves and lakeside resorts.