In this file photo, a plaque of Rosneft is seen outside its headquarters in Moscow, Russia. (Mikhail Metzel/AP)

BP has agreed to sell its half of a troublesome but lucrative joint venture in Russia to the state-controlled firm Rosneft for nearly $28 billion in cash and stock, the company announced on Monday.

The two-step deal will leave BP with $12.3 billion in cash, a 19.75 percent stake in Rosneft and two seats on Rosneft’s nine-person board.

Rosneft, Russia’s biggest oil company, also announced that it had agreed separately to buy out the Russian partners in TNK-BP for $28 billion in cash, adding to Rosneft’s already extensive holdings.

The deal will extricate BP from TNK-BP, the joint venture with a group of Russian tycoons who were often at odds with BP over its management. Now the London-based oil giant will have a substantial minority stake in the politically well-connected Rosneft, whose chief executive is Igor Sechin, a former deputy premier and longtime ally of Russian President Vladi­mir Putin. The Russian state currently owns 75 percent of Rosneft.

“By becoming Rosneft’s undisputed principal Western partner — an arrangement endorsed at the highest levels of the Kremlin — BP solidifies its position in the largest oil-producing country and will be able to access exploration opportunities (including the Arctic) that few non-Russian companies get,” Pavel Molchanov, energy analyst with the investment firm Raymond James, wrote in a note to investors Monday.

At midday, BP’s shares were at $42.61, down 1.1 percent.

The deal will strengthen the position of Rosneft, already one of the world’s most massive state-owned oil companies, and bolster Putin’s policy of resource nationalism. The acquisition of TNK-BP, Russia’s third largest oil company, will give Rosneft control of nearly half of Russia’s oil production, Molchanov said. He added that Rosneft’s oil production would be twice as large as the next largest Russian oil company, Lukoil; 12 percent larger than Exxon Mobil’s; and 50 percent larger than Royal Dutch Shell’s.

The sale of TNK-BP also marks the end of a venture initially seen as a sign that Putin’s Russia was open for foreign investment. BP’s then-chief executive John Browne and Russian financier Mikhail Fridman signed agreements in the presence of Putin and then-British Prime Minister Tony Blair. A gala reception was held at the Kremlin Armory for 300 guests from the worlds of business and politics.

“This is state capitalism with joint ventures with foreign large companies, which is probably Putin’s new model,” Anders Aslund, senior fellow at the Peterson Institute for International Economics, said in an e-mail. He said that Russia’s leaders realize that improved output from older fields in West Siberia “is coming to an end and that most of the new oil must come from the Arctic offshore. They understand that only super majors can do this.”

But these new joint ventures are for specific exploration projects, with Rosneft clearly in corporate control. Rosneft already has such ventures with Exxon Mobil, Norway’s Statoil and Italy’s ENI to develop offshore areas. Aslund said BP would probably get a region to develop as well.

Aslund lamented the lack of competition and foreign direct investment in Russia’s oil industry and criticized the concentration of ownership in a state-owned company lacking in expertise. Rosneft has also been controversial because it swallowed up the assets of Yukos, a private oil company whose chief executive Mikhail Khodorkovsky was jailed for tax evasion. That case has been widely condemned by human rights groups as trumped up because of Khodorkovsky’s political opposition to Putin.

BP said that in 2011 Rosneft produced 2.45 million barrels a day of oil, up 52 percent since 2006. The acquisition of TNK-BP will add about 2 million barrels a day of oil production.

Rosneft also holds 18.35 billion barrels in proved oil reserves (nearly half of it undeveloped) and another 5.8 billion barrels of unconventional oil reserves — only moderately less than the total U.S. proved oil reserves. The company has a market capitalization of nearly $75 billion.

The agreement represents the biggest move in BP’s two-year drive to reposition itself in the wake of the 2010 oil spill from a BP exploratory well in the Gulf of Mexico. The company has sold about $35 billion in assets to cover claims related to the spill, and it is in talks with the Justice Department over spill fines and penalties that will add billions more to the cost.

The new BP will be smaller, but will still rank as one of the world’s top five oil and gas companies, known as the supermajors.

Under the terms of the Russia deal, BP will first sell its half of TNK-BP for $17.1 billion and 12.84 percent of Rosneft. BP would then use $4.8 billion of the cash consideration to acquire a further 5.66 per cent stake in Rosneft from the Russian government. BP would acquire the Rosneft shares from the Russian government at a price of $8 per share, a premium of 12 percent to the Rosneft share closing price on Oct. 18, the day Rosneft submitted its bid to BP. Including BP’s current 1.25 percent stake in Rosneft, the London-based oil giant would own 19.75 percent of Rosneft.

BP will lose a valuable dividend stream of about $2 billion a year with its exit from TNK-BP, and BP’s net oil production will drop about 31 percent, Molchanev estimated.

But many analysts believe there is more potential for growth at Rosneft. BP’s announcement Monday noted that Rosneft had a net income of $10.8 billion in 2011 and paid a dividend of 25 percent of its net income. That will grow larger now with Rosneft’s acquisition of TNK-BP.

“Rosneft is set to be a major player in the global oil industry,” BP chairman Carl-Henric Svanberg said in a statement. “This material holding in Rosneft will, we believe, give BP solid returns. We consider that this is a deal which will deliver both cash and long term value for BP and its shareholders. It provides us with a sustainable stake in Russia’s energy future and is consistent with our Group strategy.”

 The sale concludes a decade-long saga for the TNK-BP joint venture. In 2003, BP invested $8 billion to acquire half the venture. Since then, TNK-BP has paid BP about $19 billion in dividends as better technology boosted output and soaring oil prices boosted revenue.

But the Russian partners, part of the AAR group, bickered with BP over board appointments, the size of dividend payments and whether TNK-BP should try to expand outside Russia, potentially competing against BP itself. BP’s chief executive, Bob Dudley, previously served as head of TNK-BP and essentially fled Moscow amid an escalating and increasingly politicized dispute.

Management of TNK-BP had settled down since then, but things took a turn for the worse last year after BP concluded an agreement with Rosneft in which BP would help Rosneft explore Russia’s Arctic regions. The AAR group blocked the deal, asserting that their joint venture agreement said that BP could only work in Russia through the TNK-BP joint venture. Exxon Mobil later stepped in and replaced BP in that project. BP and TNK had not agreed on a dividend payment for this year.

The AAR partners had earlier refused a $30 billion joint offer from BP and Rosneft, but on Monday the AAR chief executive Stan Polovets issued a statement saying that “this deal provides a clear and transparent exit path for the AAR shareholders at a fair market price.”

AAR includes the Alfa Group, one of Russia’s largest privately owned investment groups; Access Industries, a privately held industrial group; and Renova Group, a private industrial group.

“Had it not been for the dysfunctional relationship between BP and its so-called partners, TNK-BP could have continued its successful track record as Russia’s third-largest oil company,” Molchanov said. “But this is one marriage that had to end.”