Anti-corruption activist Alexei Navalny probably won’t become the next mayor of Moscow. But thanks in part to what he learned from the likes of Barack Obama and Kevin Spacey, he's treating Russians to something they haven’t seen in a long time: a true grassroots political campaign.

In a country that has become accustomed to predetermined electoral outcomes, Navalny is a rare case of a candidate who has something to fight for. Sometime around the Sept. 8 election date, an appellate court will decide whether to send him to prison for five years on trumped-up charges of stealing lumber from a state-owned company. The mayoral race is a chance to show the Kremlin that he is a political force to be reckoned with and thus to keep his freedom.

The election itself is a result of vigorous anti-government demonstrations in which Navalny played a central role. In 2012, President Vladimir Putin brought back regional elections in a concession to the protesters. Moscow Mayor Sergei Sobyanin, a Putin appointee, decided to hold a vote to boost his legitimacy, on the expectation that his opponents would largely consist of also-rans from pliant political parties.

Navalny, popular on social networks but virtually unknown to a TV-viewing audience, started out with no cash and no campaign team. He invited Leonid Volkov, a technology entrepreneur from the Ural Mountains city of Yekaterinburg, to serve as his chief of staff. Volkov had never managed a political campaign before, but then there hadn't been any campaigns in Russia for years. The two set up a headquarters and a bank account and started accepting donations and signing up volunteers. By early August, according to Volkov and Navalny, the campaign had more than $1 million and 14,000 volunteers.

In the last two months, teams of Navalny supporters have set up 1,000 street-corner "cubes," made from steel tubing and cloth imprinted with Navalny's pictures and slogans. Two volunteers man each cube, handing out literature and extolling the candidate's virtues. Other volunteers canvass from door to door. Thousands of Muscovites have registered on a special website, agreeing to post leaflets, talk about Navalny to their neighbors and do other small jobs that require only a few minutes a day. Moscow is full of cars with Navalny bumper stickers, hardly ever used in previous Russian campaigns.

The candidate has traveled tirelessly around Moscow, handing out newsletters in the subway and holding more than 70 meetings with voters in remote parts of the city. Everywhere, he has voiced the simple message that with less corruption, more of Moscow's $57 billion budget could go to the city's real needs. Navalny has also exploited the popular theme of curbing illegal immigration, drawing criticism from his liberal supporters but gaining ground with the city's more xenophobic majority.

"I have been accused of being a virtual character," Navalny said in an interview with New Times magazine. "Now, I am the most offline politician in Russia. It's cool."

Navalny's opponents quickly noted similarities between his campaign and Obama's 2008 presidential drive, from the change-oriented slogans to the poses both candidates struck in official photographs. "Navalny has blatantly ripped off about 90 percent of his campaign from Obama," wrote Kristina Potupchik, formerly a top organizer in the pro-Putin youth movement Nashi.

Navalny cited the TV shows House of Cards (which stars Spacey as a manipulative politician), The Wire and Homeland as inspirations for his campaign. Other campaign ideas came from Navalny's meetings with U.S. politicians during his time as a Yale World Fellow in 2010.

As the race unfolds, Navalny is constantly under pressure from Putin's repressive machine. The Prosecutor General's Office accused him of receiving foreign funding, based on the Internet addresses of Russians who transferred money to his campaign account while on vacation abroad. Police broke into an apartment where activists stored Navalny literature and stickers, and raided a Moscow print shop hoping to catch Navalny paying with cash rather than out of his campaign fund. At a recent meeting with voters, police led Navalny away for drawing too big a crowd to a public park. He was released the same night.

True to his corruption-fighting reputation, Navalny accused his rival Sobyanin of illegally obtaining an expensive apartment for his daughter and of helping another daughter set up a business selling designer furniture to the government. In response, Navalny's rivals have put a lot of effort into proving he is not Mr. Clean. They have falsely alleged that he owns a villa in Spain and focused attention on such things as the price of his campaign van, a Chevrolet Express Explorer, and an expensive-looking jacket he recently wore on the subway.

Navalny's ill-wishers achieved some success by revealing that he was part-owner of an inactive firm in Montenegro. After Volkov denied that the firm ever existed, Montenegrin authorities confirmed that the company was real. Volkov's ill-advised denial made a dent in Navalny's shining armor, even though a dead shell company without a bank account does not violate Russia's ban on ownership of foreign property by candidates.

"Navalny is surrounded by so many dubious situations, dubious people, dubious deeds, that it's impossible to take it on faith that he is not a crook," author Eduard Limonov wrote in the pro-Putin daily Izvestia.

Navalny is gaining in the polls. According to the research company Synovate Comcon, 20.3 percent of potential voters supported Navalny as of Aug. 21, up from 10.7 percent in July. Stolid, taciturn Sobyanin went from 78.5 percent to 62.5 percent over the same period.

Even 20 percent would be a formidable result for Navalny, a 37-year-old lawyer living in a small apartment on the outskirts of Moscow, in a race against an incumbent backed by Putin and all the might of his financial and propaganda machine. It would demonstrate what ordinary people can do even within the constraints the Putin regime if they dare to challenge those constraints.

"Today, Navalny is the only candidate who can turn the vote into a ballot of trust in the current government -- not just of Moscow, but of Russia as a whole," wrote television journalist Yevgeni Kiselyov.

Unless Navalny ends up in prison after the vote, he is likely to keep running in further elections, gaining ground every time as he gains experience.

(Leonid Bershidsky, an editor and novelist, is Moscow correspondent for World View.)