By Olga Razumovskaya 

MOSCOW--The Bank of Russia raised its key interest rate on Friday for the third time in five months in a surprise move, and warned there may be more to come if political shocks prevent high inflation from coming down.

The central bank had been expected to keep the rate steady after raising it twice since early March, when Russia's annexation of Crimea led local and overseas investors to flee for safer markets, causing the ruble to tumble to a record low. The weaker currency pushed up the price of imports, leading to a jump in inflation.

Instead, Friday, the central bank bumped up its main rate by half a percentage point to 8%.

"Russia is a country which is experiencing severe outflows and an uncertain political environment. They just don't want inflation out of control," said Luis Costa, an analyst at Citigroup.

Despite traders and investors being wrong-footed, the market reaction was muted. The Russian ruble edged marginally stronger against the U.S. dollar, before slipping to trade slightly weaker, at 35.12. Year-to-date, the ruble has weakened 7% against the dollar, albeit with a large recovery since March. Equity markets extended earlier losses; by midmorning, the Micex was down 1.4% while the dollar-traded RTS index was down 1.6%.

Economists and strategists said the geopolitical tensions were at the forefront of investors' minds, rather than monetary policy. "The decision will do little to the foreign exchange rate, unless political risks and risk of further Western sanctions against Russia recede," said Michal Dybula, an economist at BNP Paribas.

The central bank, meanwhile, is underscoring a commitment to fighting inflation rather than tackling weak economic growth, economists said. Russia has seen a moderate recovery in activity, but the central bank estimates that gross domestic product growth rate was close to zero in the second quarter.

On the other hand, consumer prices were up 7.5% on the year as of July 21, well above the bank's 5% year-end target and 4% medium-term target. The central bank said it expects inflation to moderate and should end the year at around 6% to 6.5%. But it warned that there are a number of lurking risks that could threaten that outlook.

Those risks have increased as a result of the "geopolitical tension" and its potential impact on the ruble. The central bank also cited potential changes in tax and tariff policy. The combination means inflation expectations remaining heightened and there is a risk that inflation will exceed the target in coming years, it said.

"Should the inflationary risks persist at a high level the Bank of Russia will continue hiking the key rates," the central bank said.

Josie Cox and Chiara Albanese in London

Write to Olga Razumovskaya at olga.razumovskaya@wsj.com