Facebook has announced it will move away from coal and power its operations – including datacentres – with clean and renewable energy.

The move follows a two-year campaign by environmental group Greenpeace, which argued that the company's massive energy consumption was contributing significantly to climate change.

The agreement comes after Greenpeace united 700,000 supporters behind its Unfriend Facebook campaign to lobby the company to change its energy policies. "This move sets an example for the industry to follow," said Tzeporah Berman, co-director of Greenpeace's international climate and energy programme. "This shift to clean, safe energy choices will help fight global warming and ensure a stronger economy and healthier communities."

In April 2011, a Greenpeace report, How Dirty is your Data?, calculated that 53.2% of Facebook's electricity was generated by coal. Energy consumption by datacentres is growing rapidly and each of Facebook's US datacentres is estimated to consume the same electricity as 30,000 US homes.

Facebook said it wanted to develop its platform to work more closely with Greenpeace to "promote environmental awareness and action" after the two organisations published a joint statement on future collaboration.

Marcy Scott Lynn, of Facebook's sustainability programme, said it looked forward "to a day when our primary energy sources are clean and renewable, and we are working with Greenpeace and others to help bring that day closer. As an important step, our datacentre siting policy now states a preference for access to clean and renewable energy."

She added that Greenpeace had been "particularly effective" in using Facebook, saying: "We are excited to work with them to explore new ways in which people can use Facebook to engage and connect on the range of energy issues that matter most to them – from their own energy efficiency to access to cleaner sources of energy."

Facebook's commitment to renewable energy "raises the bar for other IT and cloud computing companies such as Apple, IBM, Microsoft, and Twitter", said Casey Harrell, senior IT analyst for Greenpeace International.

The environmental group has argued that IT companies, by increasing their electricity consumption while avoiding increasing demand for coal, could become a strong force in helping move countries to low-carbon economies.

In October, the company announced plans to build a "green" datacentre in Lulea in northern Sweden that would handle all data processing from Europe, the Middle East and Africa. Powered primarily from renewables, the planned facility will cover 30,000 square metres - about the size of 11 football pitches.