One in four of Scotland's beaches are in a "poor" state because of toxic contamination from sewage and animal waste, according to an analysis by the Scottish Environment Protection Agency (Sepa).

The Scottish Government's pollution watchdog has given 21 bathing waters all around the coast a rock-bottom rating under tough new European safety standards. This means that bacteria and viruses in the water could pose serious risks to the health of paddlers, swimmers and surfers this summer.

Six of the bathing waters rated as poor are in Ayrshire, four in Dumfries and Galloway, and three around the Moray Firth. Two are in Aberdeenshire, two in East Lothian, and one each in Edinburgh, Angus, Fife and the Scottish Borders.

Seven of the beaches badly polluted by overflowing sewers and animal faeces have previously been given Seaside Awards by the government-backed charity, Keep Scotland Beautiful. One of the reasons for winning the awards is said to be "good water quality".

But the campaign group, Surfers Against Sewage, pointed out that the award-winning bathing waters were so dirty that bathers had a one in seven chance of contracting gastroenteritis. It would be a "mistake" to suggest that they were clean, safe or had good water quality, argued the group's Andy Cummins.

"The tougher standards have been introduced to offer the public better protection against a wide array of significant health risks," he said. "Those beaches that fail urgently need to adopt new actions and measures to ensure water quality is safe for the public."

This year is the first time that the 2006 European directive on bathing water standards comes fully into force. It is much stricter than the previous 1976 directive, which has guided safety limits until now.

Under the new directive, Scotland's 84 officially designated bathing waters are tested over four years for bacteria linked to human and animal wastes, E Coli and intestinal enterococci. The contamination can cause ear, nose, throat and stomach infections and, in extreme cases, be fatal.

As well as the 21 beaches classed as poor, a further 13 across Scotland are rated as just "sufficient". Nine of those have also been given Seaside Awards by Keep Scotland Beautiful.

At the other end of the spectrum, 22 beaches are rated at "excellent", meaning they have very low levels of contamination. They include Pencil Beach at Largs in North Ayrshire, Gullane Bents in East Lothian, Ruby Bay at Elie in Fife, Broughty Ferry in Dundee and Achmelvich, near Lochinver in Highland (see tables).

The Green MSP Alison Johnstone is planning to write to Sepa and local authorities asking why some bathing waters are performing so poorly and what they are doing about it. "We love our beaches but for us to have confidence in them we need clearer information," she said.

She called on ministers to prevent "mixed messages" by improving coordination between public bodies. "The way Keep Scotland Beautiful and Sepa classify these beaches should be much more consistent," she maintained.

The Marine Conservation Society was "delighted" by the introduction of the new safety standards for bathing waters. Although water quality had been slowly improving "there was still some way to go", according to the society's Scotland manager, Calum Duncan.

He said: "Malfunctioning combined sewerage overflows and diffuse pollution continue to impact on coastal water quality so we would urge continued investment to identify, monitor and fix problems."

According to Sepa, heavy rain is "the biggest threat to water quality". This is because it causes diluted sewage to be discharged from the sewerage overflows, and animal faeces to be washed off farmland into rivers and to the sea.

Sepa's environmental quality manager, Calum McPhail, stressed that three-quarters of Scotland's bathing waters were likely to be classified as excellent, good or sufficient. The predicted classifications were only "initial estimates", he said

"We expect further improvement this year, but some bathing waters are still unlikely to reach the 'sufficient' classification," he said. The estimates relied on data as far back as 2011, when the rules were different, and didn't take account of more recent investments to control pollution.

There had been a major improvement since 1988, when 13 of Scotland's 28 designated bathing waters failed the safety limits, McPhail pointed out. Last year, two out of 84 bathing waters failed.

He added: "Our challenge, therefore, is to build upon the progress made under the previous directive to achieve corresponding improvements in 2015 and beyond through further investment and infrastructure improvements."

Keep Scotland Beautiful pointed out that good water quality was only one of 28 criteria used by the independent jury that made the Seaside Awards. "The criteria are designed to reflect the whole visitor experience and they also recognise excellence in beach management, on-site facilities, benefits to local people and the tourism economy of the area," said a spokesman.

"On water quality standards, Keep Scotland Beautiful is guided by the European bathing water directive. We welcome the revised directive and the higher standards which will further protect the health of bathers," he continued.

"However, the Seaside Award recognises that beaches are used for a wide range of activities from picnicking to sports, and that well managed facilities, clean sand, and safety provision are equally important to users."

The Scottish Environment Minister, Dr Aileen McLeod, emphasised the need to be "diligent" protecting bathing waters. "This includes ensuring our waste water facilities are operating efficiently, encouraging farmers to consider carefully the risk of organic manures entering our rivers, educating householders and businesses on the risk from septic tanks or misconnected drains," she said.

"Sepa and Scottish Water have worked closely with Scottish Government and other partners over the last few years to make improvements. We will continue to work to ensure our bathing waters are of good quality for the Scottish public and our many visitors to enjoy."