MOSCOW — The hoodie stayed back at the hotel when Mark Zuckerberg, the founder of Facebook, met Russia’s prime minister and former president, Dmitri A. Medvedev, on Monday.

“Good conversation with Prime Minister Medvedev,” Mr. Zuckerberg wrote on his Facebook wall beside a picture of the two, in suits and grinning, at the Russian leader’s residence outside Moscow.

Mr. Zuckerberg also visited Red Square — in his hoodie — ate at McDonald’s and helped judge a competition for Russian programmers under way in Moscow in his first visit to Russia, a country that is in important ways pivotal for Facebook.

One of Google’s founders, Sergey Brin, is Russian by birth. For Facebook, the tie is more oblique: The country is an important test case for the balancing act Facebook is undertaking as a new media company in countries that are important commercially but have traditionally heavily regulated their old media, if not censored it. And two of Facebook’s largest investors are Russian.