* Pussy Riot members say they were struck with whips
* Women tried to perform protest song in Sochi (Adds Cossack comment)
SOCHI, Russia, Feb 19 (Reuters) - Members of the all-women Russian protest group Pussy Riot said they were beaten with whips on Wednesday by Cossacks who are helping patrol Sochi during the Winter Olympics.
Nadezhda Tolokonnikova and Maria Alyokhina, who served prison sentences over a protest in a church against President Vladimir Putin, said they were attacked in Sochi as five band members tried to perform a song.
"Under the banner Sochi 2014, to the sound of 'Putin will teach us to love the homeland', Cossacks attacked Pussy Riot, beat us with whips and sprayed a lot of pepper gas at us," Tolokonnikova wrote on Twitter.
Video purportedly of the incident posted on a Russian television website showed Pussy Riot members pulling trademark, brightly coloured ski masks over their faces and performing a song in front of a wall decorated with the Sochi Games design.
What appeared to be pepper spray was aimed at one of them, a Cossack was shown beating several people with a whip and the masks were roughly pulled off the protesters' heads.
Alyokhina tweeted photographs of blood dripping down the face of a supporter after the attack. Another showed red marks across Tolokonnikova's chest.
David Khakim, an activist who was briefly detained over a one-man protest in Sochi this week, said he had witnessed the attack.
"The Cossacks sprayed gas in my eyes. They started beating us with whips after which they started choking us in front of a police officer," he wrote on Twitter.
Cossacks have enjoyed a revival under Putin and are being used to enforce security around the Olympic Games.
"Most likely, this is some sort of a cheap provocation," said Konstantin Perenizhko, a deputy to the regional Cossack military leader.
Neither part of the police nor military, Cossacks, once the patrolmen of the Russian borderlands, are meant to maintain order and work with police to make arrests.
Alyokhina and Tolokonnikova were detained on suspicion of theft in Sochi on Tuesday but were later released, less than two months after their release from prison under an amnesty.
The pair had been serving two-year jail terms for hooliganism motivated by religious hatred after performing a profanity-laced protest song against Putin in Moscow's main cathedral in February 2012.
Western governments said the sentences were excessive, and Kremlin critics called the trial part of a clampdown on dissent during Putin's third presidential term.
Tolokonnikova said she and Alyokhina had also been detained for seven hours on Sunday and for 10 hours on Monday, though their presence in Sochi had not been advertised.
Putin has staked his reputation on the Sochi Games, hoping they would show the world Russia's modern face more than two decades after the collapse of the Soviet Union. (Reporting by Thomas Grove, additional reporting by Ludmila Danilova and Gabriela Baczynska)