MOSCOW — Russians awoke to an extraordinary scandal on Tuesday with the minister of economic development detained on charges of soliciting a $2 million bribe — the highest-level official arrested in Russia in decades.

The minister, Aleksei Ulyukayev, 60, a liberal stalwart with a trademark porcupine haircut, was detained in the middle of the night, a Soviet-like tactic against officials who had fallen into disfavor that many thought had been retired.

Mr. Ulyukayev was charged with extorting a $2 million bribe from Rosneft, the state oil giant, as a thank-you for endorsing a deal for it to buy a chunk of Bashneft, a smaller, government-owned oil company that the Kremlin recently confiscated from an oligarch.

Late on Tuesday, President Vladimir V. Putin dismissed Mr. Ulyukayev from the minister’s job he had held since 2013, citing a “lack of trust.”

It was a rare bribery case to reach behind the high red walls of the Kremlin — though relatively small in a country where corruption is rampant — and to an unusual degree parted the curtains on the extended, opaque battle within the ruling elite over the direction and control of the sickly Russian economy.

Amid myriad questions about what actually happened, which may never be made public, one explanation emerged as the favorite.

The Kremlin and its allies, struggling to right an economy waterlogged by two years of recession, are seeking a life raft, analysts said. Mr. Ulyukayev’s mistake was to question their methods publicly.

In this line of thinking, Mr. Ulyukayev was being punished for initially trying to block Rosneft from expanding its reach by purchasing Bashneft, and for generally restraining its growth. On a larger scale, the arrest served as a warning from the increasingly dominant security services that no one should challenge them.

“I think the purpose of the whole thing was to eliminate resistance,” said Vladimir S. Milov, an opposition politician and former deputy minister of energy who now leads a think tank. “The message is, ‘Don’t stand in my way.’ A clear message for all future deals.”

The basic scenario goes something like this:

As the head of Rosneft, Igor Sechin, a former K.G.B. agent and Putin confidant, is sitting on about $15 billion in cash. With the state’s two main reserve funds dwindling, the Russian government covets that cash.

Mr. Sechin’s purchase of state assets transfers that money directly into the Russian treasury. It also increases his power, though there was a small wrinkle in the form of a law suggesting, except in extreme instances, that state assets should be sold into private hands. A private company, Lukoil, also expressed interest at a lower price.

As minister of economic development, Mr. Ulyukayev had to sign off on the sale of any state assets. So Bashneft was a major test case.

Mr. Sechin wanted it for Rosneft, despite the law and the widespread, negative public perception that the elite was once again, as it did in the 1990s, abusing privatization laws to seize commodity resources at bargain prices.

Mr. Ulyukayev tried to postpone the deal, but Mr. Putin backed the sale after initially hesitating. In October, it was announced that Rosneft would acquire a little more than half of Bashneft for more than $5 billion.

Mr. Sechin is known for a take no prisoners attitude toward anyone who challenges him, so the bribery charges against Mr. Ulyukayev were interpreted as revenge.

For Mr. Putin, the nation’s special reserve funds have served as Russia’s main, tangible economic cushion.

“The reserve funds have been something sacred. Putin always refers to them when he talks about economic difficulties,” Mr. Milov said. “They have been used as a strong, public indicator that the state still has capabilities.”

But they are shrinking fast with no economic revival in sight. Two sovereign funds, the Reserve Fund and the National Wealth Fund, are now down to less than $104 billion, compared with a combined $160 billion at the beginning of 2015, according to the Finance Ministry’s website.

The financial reserves are expected to run out by the end of 2017, just as Mr. Putin faces a campaign for a fourth term in the spring of 2018.

The Rosneft stash would help tide over the country for a longer period while the Kremlin ties its hopes to a rebound in the price of oil and the possible lifting of Western sanctions imposed over Russia’s annexation of Crimea and the Ukraine crisis. Prospects for the latter brightened with President-elect Donald J. Trump’s criticism of the American policy of isolating Russia.

For now, the Russian economy hovers around zero growth, and consumers still struggle with inflation caused by a sharp drop in the ruble, along with food restrictions imposed in response to the Western sanctions.

With minimal outside investment, Russia’s economic fate is increasingly in the hands of the state. New statistics from the federal antimonopoly service show that the government controls about 70 percent of the economy, compared with 35 percent in 2005.

Olga V. Kryshtanovskaya, a leading sociologist who studies the Russian elite, said the Ulyukayev case cast a shadow over the entire government. “People resent the fact that they had to give up French cheese in order to support the president’s policies and such corruption cases still erupt,” she said in an interview.

On Tuesday, the Kremlin cranked its information machinery into high gear to paint the arrest as part of a continuing anticorruption crusade that has included the arrest of three governors in the last two years.

A report called “Fight Against Corruption” was the top one for much of the day on the main state-run television news network. A caravan of politicians appeared on screen to praise the arrest as evidence that nobody was above the law.

Mr. Ulyukayev was charged with extorting a large-scale bribe, Svetlana Petrenko, a spokeswoman for Russia’s Investigative Committee, said on state television. Mr. Ulyukayev threatened to use his official standing to create future problems for Rosneft, she said, and was detained on Monday while accepting $2 million.

Russian security services had monitored Mr. Ulyukayev’s telephone calls for a year, and Rosneft had put the $2 million in a safe deposit box, according to various news reports, but the accused had not touched it.

Timofei Gridnev, identified by Business FM radio as Mr. Ulyukayev’s lawyer, said the minister denied all the charges, calling them a “provocation” by Rosneft against a government official.

Mr. Ulyukayev was put under house arrest for two months.

Another school of thought, though not as widespread as the revenge story, holds that the bribery scandal was meant to hurt Rosneft, to show that it was a source of corruption and so to weaken Mr. Sechin.

Evidence for that was harder to find, however, especially because various politicians had demanded Mr. Ulyukayev’s head. Gennadi A. Zyuganov, the leader of the Communist Party, suggested that Mr. Ulyukayev was happy to enrich himself while denying the funds needed for a children’s cancer hospital in Moscow.

Dmitri S. Peskov, Mr. Putin’s spokesman, told Russian reporters, “This is a very serious accusation which calls for very serious evidence.” He said a court would make the ultimate determination about Mr. Ulyukayev’s guilt or innocence.

There was some mocking criticism of the charges from business leaders and others.

Apparently referring to Mr. Sechin’s reputation, Alexander N. Shokhin, the president of the Russian Union of Industrialists and Entrepreneurs, told the website Gazeta.ru that anyone who tried to shake down Rosneft for money should be the subject of a psychiatric investigation rather than a police investigation.

“If Alexei Ulyukayev had been accused of running over an old lady while driving a Gelandewagen at high speed through Moscow late at night, even that would look more probable,” Mr. Shokhin said.

Ilya Shumanov of Transparency International, which fights corruption, told RBC Daily, a financial newspaper, that a $2 million bribe was a paltry, unrealistic sum in Russia’s moneyed oil industry, suggesting that was the kind of sum a deputy mayor might solicit.

A recent shake-up among Mr. Putin’s advisers prompted some analysts to suggest that Mr. Ulyukayev’s arrest was part of a trend of replacing seasoned veterans with a younger generation less likely to question the president’s decisions.

Many analysts, however, considered the arrest part of a different trend: the increasing power of the siloviki, or members of the security services, over the whole government.

Oleg Feoktistov, the head of security at Rosneft and identified in news reports as the main executive behind Mr. Ulyukayev’s arrest, used to run internal security and corruption cases in the federal security service, or F.S.B.

“In the past six to eight months, these repressions have become more widespread,” said Kirill Rogov, an independent political analyst. “This is directly linked to the new people occupying new posts in the F.S.B., who want to expand their turf.”