* Putin signs law on punishment for mass riots, "terrorism"
* Russian authorities wary of unrest spreading after Ukraine
* Critics fear crackdown on Internet (Updates with protest, detentions)
By Gabriela Baczynska
MOSCOW, May 6 (Reuters) - While all eyes are turned to Ukraine, President Vladimir Putin has quietly enacted laws which opponents say will strengthen his hand in a battle against dissent in Russia.
Putin signed laws on Monday envisaging tougher punishment for people involved in riots and imposing life sentences for various "terrorist" crimes. He also approved tighter controls on bloggers, some of whom have emerged as opposition leaders and have used the Internet to criticise Putin and arrange protests.
"All this tightening will be applied only for political ends," said Dmitry Gudkov, a member of parliament who helped organise rallies against Putin in the winter of 2011-12.
The moves underline Kremlin concern that the unrest in Ukraine, where demonstrations put the Moscow-backed president to flight, might encourage protests in Russia, even though the annexation of the Crimea peninsula from Ukraine has helped push Putin's ratings to their highest level since late 2010.
The new measures were announced hours before a few hundred people gathered on Moscow's Bolotnaya Square to mark the second anniversary of a major rally there that was broken up by riot police on the eve of Putin's inauguration for a third term.
The dozens of arrests on May 6, 2012 were widely seen by Kremlin critics as the start of a clampdown on the opposition. Authorities denied permission for Tuesday's rally and activists said police detained 12 people who unfurled signs with slogans such as "Russia is not a prison". However, they later let a few hundred others gather quietly, without banners, on the square.
Security is tight in central Moscow this week ahead of a military parade on Red Square on Friday, presided over by Putin, marking the Soviet victory over Nazi Germany in World War Two.
Dmitry Agranovsky, a lawyer for defendants in what became known as the Bolotnaya trial following the protest two years ago, said Kremlin fears of a spillover from the uprising in Kiev meant an example had been made of his clients.
Seven received jail terms of up to four years although the Kremlin denies using the courts for political ends and dismisses talk of a clampdown on the opposition.
"Our defence strategy is to draw a clear line between Bolotnaya and the protests in Kiev," Agranovsky said on Tuesday. "We cannot be punished for what happened in Kiev."
The laws signed by Putin, and posted on Russia's official legal information website, envisage prison terms of eight to 15 years for organising "mass riots accompanied by violence, pogroms, arson, destruction of property, use of weapons, explosive devices, explosive and poisonous substances".
They introduce prison terms of up to 10 years and fines for taking part in "training" with the purpose of staging mass riots, as well as jail sentences for recruiting people for "extremist activity".
The laws also expand the powers of the Federal Security Service, once led by Putin and a successor to the KGB in which the president was an officer in the 1970s and 80s. The legislation raised to life imprisonment the possible penalty for crimes including organising and financing terrorism and being linked to or "performing other terrorist activity".
The Kremlin has gradually stifled the protest movement that at its height gathered tens of thousands in the streets of Moscow but failed to unite behind a single leader or ideology and lost momentum after Putin won the 2012 presidential race.
The opposition have been further sidelined during the Ukraine crisis because criticising the annexation of Crimea, handed over to Ukraine by Soviet leader Nikita Khrushchev in 1954, would win almost no popular support in Russia.
Some of the staunchest Kremlin critics, including leftist leader Sergei Udaltsov, echo the Kremlin's line that the Kiev protests which ousted the president were staged by "fascists".
Only a small number of opposition leaders have voiced any criticism of Putin's stance on Ukraine, including Gudkov, who has said taking over Crimea will drain funds from state coffers.
"Putin has rallied Russians behind him but this was his last trump card in a dangerous game," Gudkov said. "For now people may focus on hating 'fascists' in Kiev, but Crimea will cost citizens dear in the end and the economy is already in trouble." (Writing by Gabriela Baczynska; Editing by Timothy Heritage and Alastair Macdonald)
Our Standards: The Thomson Reuters Trust Principles.