Twenty-one climate change activists were sentenced on Thursday for aggravated trespass after occupying a gas-fired power station last year.

Sixteen of the activists were given community service orders of 150-200 hours, while the other five received 18-month conditional discharges.

The activists occupied EDF's newly built West Burton power plant in Nottinghamshire in October, with several protesters remaining strapped to a cooling tower at the site for more than a week, the longest such occupation in the UK.

During sentencing at Nottingham magistrates court, district judge Leo Pyle said: "It is right to say that I took into account the conscientious motives of all of you." He added: "What you planned, you executed to perfection."

The protesters, from the No Dash for Gas group, said they were campaigning against plans for a new generation of gas plants in the UK. They argue these will endanger attempts to curb global warming by reducing emissions of carbon dioxide and will force more households into fuel poverty.

One of the activists, Ewa Jasiewicz, who received 150 hours' community service, told the Guardian: "We feel relieved. This chapter is over now but the action to stop the dash for gas needs to keep going. We are all still committed to climate and social justice."

A spokesman for EDF Energy said: "Today's sentencing was solely a matter for the magistrates court. We have invited a range of groups and individuals – including No Dash For Gas – to discuss the company's response to such demonstrations in future." He added: "We share the protesters' commitment to tackling climate change. We are Britain's largest generator of low-carbon electricity."

Mike Schwartz, a solicitor from Bindmans acting for the defendants, said: "It was right for the judge not to send them to prison, but the fact remains that protest around urgent climate issues is being tackled with ferocious effort by companies and government. This has to change."

The prosecution had sought anti-social behaviour orders on six defendants, but this was rejected. "These people were acting for the best of social motives, not the worst," said Schwartz.

In March, after a public backlash, EDF abandoned a civil lawsuit seeking £5m in damages from the protesters. An online petition launched by the parents of one of the activists attracted 64,000 signatures, including those of Richard Dawkins, Mark Ruffalo, Naomi Klein and Noam Chomsky. Several hundred apparent EDF customers claimed they had switched their energy provider. EDF said it dropped the civil action as part of a settlement with the protesters, who agreed to accept a permanent injunction preventing them from entering EDF sites.

Climate campaigners scaled chimneys at Kingsnorth coal-fired power station in 2008, stopped a coal train to Drax power station in 2009, planned to shut down Ratcliffe-on-Soar coal-fired power station in 2009 and disrupted flights at Aberdeen airport in 2009. None have received jail sentences.

North Sea gas supplies are in decline and the UK has become a net importer of the fuel as volatile gas prices have led to large increases in the price of energy to households and businesses. The government says gas will be needed to "keep the lights on" as many of the UK's ageing coal-fired and nuclear power stations are taken out of service in the next few years.

In December, government's official advisers, the Committee on Climate Change, said the so-called dash for gas backed by the chancellor, George Osborne, was "completely incompatible" with the nation's legally binding carbon emissions targets.

Canadian author and activist Naomi Klein said: "Our governments have been negotiating about the climate crisis for 23 years. In that time, emissions have soared by 54%. Clearly the official, respectable, legal means of dealing with this crisis are not working. That means that what used to be radical is now rational. The people who scaled EDF's smokestacks are not criminals, they're heroes." Klein was arrested outside the White House in Washington DC in 2011 while protesting against the proposed Keystone XL oil pipeline.