Almost two years after staking a claim to lead the battle against global warming, and after two days of hard haggling over how to spread the financial pain, European leaders today agreed a package of laws aimed at cutting greenhouse gases by one-fifth within 12 years.

The complex package details how European industries, power generators, governments, and transport sectors are to effect the "triple 20" deal of reducing greenhouse gas emissions by 20% by 2020 compared with 1990 levels, of cutting energy consumption by 20% by the same deadline, and of ensuring that 20% of the EU's energy mix comes from renewable sources.

The deal will cost tens of billions of euros to implement and has been fought over ferociously for months, with governments and industrial lobbies pleading special treatment.

The politicians hailed the green pact as historic, but environmentalists denounced it as a disgrace.

With the imminent inauguration of a new US president and with UN climate talks in Poland aiming to pave the way to a global climate deal a year from now, Europe's leaders argued that today's pact sent a powerful message to Washington, Beijing, Delhi and the other key players who must commit to reducing emissions if the Earth's rise in temperature is to be kept to no more than a "safe" two degrees centigrade.

What happens next?

Four pieces of legislation to be passed next week in the European parliament will do two main things.

One will revise the world's first and biggest carbon trading system, the European Emissions Trading Scheme (ETS), so that industries start paying to pollute from 2013 via the auctioning of permits that allow you to belch tonnes of carbon dioxide and other greenhouse gases into the atmosphere. This system covers Europe's power plants and processing industries .

The second, on "effort-sharing" dictates what the 27 countries of the EU have to do at national level to cut pollution from other sectors not covered by carbon trading, such as construction, transport, and agriculture. The emissions trading scheme and the effort sharing cover all greenhouse gases.

The other two laws concern renewable energy and national targets to reach the 20% across Europe and the establishment of centrally funded pilot projects for carbon capture and storage, technology that aims to collect CO2 from power plants and bury it.

What does all this mean for Europe?

Political leaders argue that today's deal means that Europe is setting an example to the rest of the world and hope to seal a transatlantic pact with the incoming Obama administration that could result in a fledgling global market in carbon trading.

Environmental and economic standards vary hugely across the EU, from high-achieving Sweden to bottom-of-the-class Romania. The new member states of central Europe have a lot of catching up to do in terms of standards of living and are also saddled with dirty Soviet-era coal power plants. The system seeks to spread the costs and pain accordingly.

Some of the east European countries are allowed to increase their emissions, while they also benefit from a "solidarity" mechanism, getting 12% of the pollution permits for free and receive large discounts on the price of the permits for their heavily polluting power stations. This is especially crucial in Poland, by far the biggest of the new member states which generates more than 90% of its electricity from coal.

In wealthier western Europe, the claim is that the package will provide a boon to clean technology development, encouraging companies to go green, to invest in new plant, and spawn a vast renewables industry.

Who pays and how much?

Despite the "polluter pays" principle of the carbon trading scheme, there are trade-offs and exemptions galore, pushed mainly by Germany which campaigned for large concessions for its heavy industries. This could see many European companies enjoying a multibillion euro bonanza in windfall profits by pocketing their permits for free and passing on the nominal costs to consumers.

While east European power stations get big discounts on the price of carbon, west European generators pay full whack.

Processing industries, however, will get their pollution permits for free if deemed to be exposed to unfair competition from rivals outside the EU. That will mean 96% of the companies, according to expert calculations.

Under the initial proposals from the European commission, the trading scheme was to have generated €55bn (£49bn) in revenue in 2013-2020. Given the tradeoffs and free permit allocations agreed over the past two days, that pot of money will be much smaller.

Any other loopholes?

One of the most controversial aspects of the package, denounced as neo-colonial by some in the green lobby, concerns the practice of "offsetting". This enables countries and companies to meet their emissions cuts by funding projects in the developing world.

Under the trading scheme, companies can count environmental investment in the developing world towards their obligations to cut pollution in Europe. They may offset around of half their burden this way.

And similarly under the national targets, countries or companies can also offset their reductions to the tune of around 70% through projects outside Europe. Environmental activists complain that big polluters will need to do little at home to observe the new laws. Leaders counter that if Denmark builds a wind farm in, say, Cape Verde, that is an excellent thing that would not otherwise happen because Cape Verde could not afford it.

How does the trading scheme work?

It is "cap and trade", with a progressively smaller number of permits being auctioned every year. Between 2013 and 2020, the "cap" or emissions ceiling falls by 1.74% every year to produce an overall greenhouse gas reduction of 21% by 2020 compared with 2005. One permit equals one tonne of CO2. The number of permits issued falls every year.

Whether you pay for the permits or get them free of charge, say the supporters, pollution still comes down. If a company emits, say, a million tonnes of CO2, it either buys or is given a million permits. If it is dirtier, it goes to the carbon market to buy more permits. Conversely, companies are encouraged to be cleaner and can then sell surplus permits to increase earnings. On the market, the current price for CO2 is €15 a tonne, but is expected to rise to around €40.

Under the staggered reduction scheme, the cap on CO2 emissions in Europe falls from 1,974 million tonnes in 2013 to 1,720 million in 2020. This represents roughly half of carbon dioxide emissions in Europe since the other half comes from industries not included in the trading scheme.

Why do so many get to pollute for free?

It's the economy, stupid. Since the outline package was agreed in March last year, economic hard times have set in with a vengeance, triggering a backlash by governments and industries worried about job losses, the costs of combating climate change, and the threats from big corporations to move out of Europe.

Italy threatened to veto the deal. Germany's Angela Merkel shifted from being a climate chancellor to a corporate lobbyist. Poland warned electricity prices would soar and threaten the government. But everyone claimed they were a winner. Ultimately, the councils of Europe are a bazaar.