SOCHI, Russia — An environmentalist and leading critic of Russia’s preparations to host the Winter Olympics was sentenced Wednesday to serve three years in a penal colony, in a ruling that rights groups condemned as legally flawed and obvious retribution for his political activities.

Even before the ruling on Wednesday, a court had sentenced the activist, Yevgeny Vitishko, to 15 days in jail on a charge of hooliganism for swearing in public, a conviction that other environmental activists called a pretext to jail Mr. Vitishko during the Games.

The more severe sentence was handed down on Wednesday by an appeals court in Krasnodar, the capital of the region where Sochi is. It upheld a lower court ruling from December that Mr. Vitishko had violated the conditions of a suspended sentence, akin to parole, for an earlier conviction of spray painting graffiti on a fence.

Human Rights Watch and Amnesty International deplored what they characterized as trumped up charges intended to intimidate critics of the Russian government’s environmental record while preparing for the Games.