Two of Scotland's most popular beaches broke pollution safety limits this summer, posing health dangers for swimmers, surfers and paddlers.

The Sunday Herald can reveal that Heads of Ayr in South Ayrshire and Stonehaven in Aberdeenshire will tomorrow be officially branded as failures for the 2012 bathing season by the Scottish Environment Protection Agency (Sepa).

Both bathing waters recorded levels of faecal contamination above safety levels agreed by the European Union in 1976. The contamination can cause ear and stomach infections and, in extreme cases, be fatal.

At Heads of Ayr, animal faeces washed offshore during heavy rain were blamed for the contamination. According to Sepa, this had "possibly" been combined with sewage discharges. At Stonehaven, Sepa said there had been a "pollution incident" as well as heavy rainfall.

Two other beaches – Prestwick in South Ayrshire and Sandyhills on the Solway Firth – narrowly missed being classified as failures because of new rules which enable short-term pollution to be discounted if it is predicted and the public warned.

Although this year's two official failures were fewer than last year's four, the overall level of pollution in 2012 was significantly worse than in 2011. Some 49 other bathing waters failed to meet the tighter standards this year, against 39 last year.

Sepa samples 83 formally identified bathing waters around the coast up to 20 times between May and September every year. This year's official bathing season finished yesterday.

The legal standards are due to be substantially tightened up over the next three years. Sepa estimated in May that as many as 20 bathing waters could be heading for failure.

Andy Cummins, from campaign group Surfers Against Sewage (SAS), demanded tougher action by Sepa and Scottish Water.

"Failing bathing waters present bathers and surfers with an alarming array of health risks. They have had 36 years to achieve the bare minimum water quality standards, so it's both shocking and shameful that many Scottish beaches are still failing."

Cummins warned that the risks to water users would get "considerably worse" if Scottish Water went ahead with plans to turn off vital ultra-violet treatment for sewage at key bathing waters. SAS is petitioning the Scottish Government to maintain year-round treatment at important recreational beaches.

According to Calum Duncan from the Marine Conservation Society in Scotland, run-off from farms and overflowing sewage outfalls were probably to blame for the pollution.

He said: "With summers set to get wetter and stormier and bathing water standards tougher, effort must be increased. All combined sewer outfalls must be mapped, monitored and, if necessary, improved."

Scottish Water said pollution incidents had dropped over the last 10 years. A spokesman added: "We have experienced the wettest summer in 100 years, and this naturally has an effect on the quality of bathing waters through increased run-off from land."

The company has been helping to encourage farmers and landowners to reduce run-off, gathering information on the impact on water quality.

Calum McPhail, Sepa's environmental quality manager, said he was pleased with the performance of the information systems that warned the public about pollution, but added: "We will be issuing a full release on this year's bathing water results on Monday, so are unable to provide fuller comment at this time."