This week Vladimir Yakunin, the head of Russian railways, political ally and friend of President Putin, unexpectedly announced he was resigning and intended to move to the upper house of parliament, the Federation Council. The news caused a fevered bout of political speculation in Moscow.  

To understand the current state of Russia's vast railway company and the fate of its powerful boss, consider the uniquely Russian symbol of the security seal. A heavy disk, once made of lead and now more likely to be a thick plastic tag, it has locked and guarded countless secret sites in Russia over the last century, from Lenin's sealed train to warehouses and prison camps.

The seal--known in Russian as a plomba--has also been an unusually good source of business for Russian Railways. Billions of security seals are used on the railways and the market in them is estimated to be worth half a billion dollars a year. For a long time, the company not only purchased seal locks from the same manufacturer, but instructed all station agents and their subordinates to sell them to all freight shippers and carriers indiscriminately. The sales plan, according to the Kaliningrad Federal Antimonopoly Service, covered 100 percent of the forecast--not even the actual--number of security seals. 

Based on Russian Railways’ purchase price, according to one participant in the market, security seals yielded the company a revenue of about eight billion rubles (117 million US dollars at current rates) annually--not counting the profits of the manufacturer.  It is harder to count what it earned from napkins, the non-transparent rental of millions of square meters of warehouse space, gigawatts of energy or banking services for millions of employees. 

Russian Railways is imperial in scale. The company generates about three percent of the country’s GDP. Its investment budget for 2015 is known to be 414 billion rubles (six billion US dollars). How much corruption it has generated is something that historians may tell us in 50 years.

Since 2005, for the ten fattest years in Russian history, Vladimir Yakunin, President Putin’s friend and political ally, has headed the company. Under his management German and Italian high-speed trains started running on modernized lines (although not at their maximum speeds), while railway stations, terminals, and rail cars smartened up, and trains began to run on time.

Yakunin successfully exploited his personal relationship with President Putin to get things done. He also burnished his patriotic credentials by organizing for example for the Holy Fire in Jerusalem's Church of the Holy Sepulcher to be transported to Moscow for Easter.

Yet there was no great overhaul of railway infrastructure in this period. Earlier this year commuter rail traffic was at a virtual standstill, even though Russian Railways had received subsidies for 2015, both for commuter rail and for long-distance passenger trains, worth almost 80 billion rubles.

Russian Railways is losing money: in 2014, it lost 44 billion rubles (645 million dollars), and in 2015 it will lose another 32 billion rubles (469 million dollars), even though it put up its prices by 10 percent—more than other monopolies. 

Since the 2008 financial crisis Yakunin has persistently asked the government for assistance. In the last three years officials reported that Putin would refer to Yakunin's “whining,” or “moaning” in meetings. In a time of stretched resources, the railways chief was asking for too much. 

Prime minister Dmitry Medvedev and his colleagues had been trying to get rid of Yakunin for years. In the summer of 2013, a fake email message briefly fooled Russian media with the news that Yakunin was being replaced by Alexander Misharin, railway executive and former governor of the Sverdlovsk Oblast. 

The railway boss was literally saved by a grouse: he was dining with President Putin on a grouse he had shot on a hunting expedition. Yakunin received a text message about his dismissal and read it out aloud to Putin, who stopped the rumor becoming a reality. 

But over the last year everything has changed in Russia. The money is running out and the Kremlin has to be coldly rational in its decision-making. The old guard is being replaced by people who are younger than Vladimir Yakunin and don’t have appetites as crazy as he does. This is the economic aspect to Yakunin’s resignation. The company needs someone who will not ask for an additional 100 or 200 billion rubles every year just so that the trains can run on time. 

There is also a political story here. Dmitry Medvedev's team applied the pressure for Yakunin to be removed. That does not mean that his successor will be their choice. There is talk of Misharin, a protégé of Medvedev, who holds the No. 2 position in the company and who was erroneously congratulated on getting the job two years ago. 

More important than the name of the man who gets to lead Russian Railways is who will appoint him.

Formally, the candidate will be chosen by Prime Minister Medvedev, who is being tipped to head the United Russia party list in the parliamentary 2016 elections. Having his own man in this powerful position would help the prime minister to organize and finance his campaign. If Putin agrees to Medvedev’s candidate, this suggests the prime minister is again turning into a genuine political actor.

On the other hand, if the new appointee is a figure named by Putin with comparable political weight as Yakunin or from the same camp, that indicates that the prime minister will remain a fringe player in both the upcoming elections in 2016 and 2018.

Konstantin Gaaze is a reporter and political commentator.

Correction: An earlier version of this piece incorrectly stated that eight billion rubles was the equivalent of 117 U.S. dollars at current rates. It should have stated 117 million U.S. dollars.