EU leaders have reached a landmark deal to cut greenhouse gas emissions by 40% by 2030, compared with 1990 levels.
The binding decision came after heated discussions at a summit in Brussels, as some members had argued that their varied interests should be protected.
Correspondents say the final deal is a compromise between countries that rely heavily on coal, and those willing to instil greater emissions cuts.
Environmental groups welcomed the deal, but said it did not go far enough.
The bloc also agreed to boost the use of renewable energy to 27% in the total energy mix and increase energy efficiency to at least 27%.
There were deep divisions within the EU on emissions cuts.
Poland, which is heavily reliant on coal, fears that the costs of decarbonising its economy will slow business growth. Its concerns at the summit were echoed by other central and east European members.
The President of the European Council, Herman Van Rompuy, said afterwards that some poorer EU members would get help - including additional funds - in reaching the agreed targets.
The UK also had opposed nationally binding targets for renewables - mainly wind, solar and hydroelectric power. It is embracing shale gas and nuclear as alternatives to the current over-reliance on oil and gas imports.
'Very modest' package
Leaders had been cautious about the prospect of a deal, before holding talks late into the night.
But in the early hours of Friday, Mr Van Rompuy, wrote in a tweet: "Deal! At least 40% emissions cut by 2030. World's most ambitious, cost-effective, fair #EU2030 climate energy policy agreed ."
The EU Commissioner for Climate Action, Connie Hedegaard, said she was "very proud" that the leaders "were able to get their act together on this pressing climate challenge".
Ed Davey, the UK's Energy Secretary, described the deal as "a historic moment".
"Europe has sent a clear and firm message to the world that ambitious climate action is needed now," Mr Davey said.
"This morning only five countries in Europe had climate targets post 2020, now 28 countries do.
"It's good for consumers because we can decarbonise at the lowest possible cost using a diverse mix of technologies. And it's good for business as it provides the certainty they have been calling for to unlock billions in low carbon investment."
Meanwhile, German Chancellor Angela Merkel said: "We made a decisive step forward."
The EU is already on target to cut its CO2 emissions by 20% by 2020, compared with 1990 emission levels.
EU officials earlier said they wanted the EU to have an "ambitious position" in the run up to the UN climate change conference in Paris in December 2015.
Analysis: By Roger Harrabin, BBC Environment Analyst
The EU calls its climate deal ambitious- but it's unlikely to achieve Europe's own commitment to avoiding the risk of dangerous climate change.
Tackling climate change needs a transformation of the world's energy economy over decades - and experts say a 40% cut in 2030 leaves too big a task for the next generation of politicians.
Europe says it accepts the need to reduce emissions by more than 80% of 1990 levels by 2050.
But this new deal leaves future leaders to cut CO2 threefold within 20 years - an effort UN experts say is nigh impossible.
The deal is a compromise between countries like the UK, willing to stretch to 50% by 2030, and Poland and others which heavily rely on coal.
Scientists and environmentalists will not be happy - but Europe's leaders have been under heavy pressure not to impose much higher energy costs, especially when the economy is struggling.
The EU leaders said the crisis in Ukraine and turmoil in the Middle East had made it clear Europe needed to be less reliant on outside sources of energy, the BBC's Damian Grammaticas in Brussels reports.
And they will now be able to press large polluters like China and India to follow Europe's lead, our correspondent adds.
However, environmentalist groups said the EU could have done more.
Joris den Blanken of Greenpeace called it a "very modest" package.
"It will mean a slowdown in clean energy development in Europe,'' he was quoted as saying by the Associated Press.
Natalia Alonso of Oxfam welcomed the 40% target but said it fell "far too short", while the European Environment Bureau, a coalition of environmental organisations, condemned the targets as "desperately ineffective".
Jeremy Wates, EEB Secretary General, said the targets needed to be higher, adding: "With this abysmal result, Europe's leaders have failed their citizens and failed the world."
In the Belgian capital, the EU leaders were also expected to agree to boost measures to stop the spread of Ebola.
The UK is expected to urge its EU partners to send more medics and equipment to West Africa, in line with the UK's help for Sierra Leone.