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, Russia’s biggest oil company, and two seats on Rosneft’s nine-person board.

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.

Rosneft, by comparison, is run by Igor Sechin, a former deputy premier and longtime ally of President Vladi­mir Putin. The Russian state currently owns 75 percent of the firm.

Rosneft also announced that it had agreed separately to buy out the Russian partners in TNK-BP for $28 billion.

The deal gives BP a stake in one of the world’s most massive state oil companies. Rosneft holds 18.35 billion barrels in proved oil reserves and another 5.8 billion barrels of unconventional oil reserves — nearly as much as the U.S. total. The company has a market capitalization of nearly $75 billion. BP said that in 2011 Rosneft produced 2.45 million barrels a day of oil, up 52 percent since 2006.

Under the terms of the 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 per cent 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 with its exit from TNK-BP, Russia’s third largest oil company. But many analysts believe there is more potential for growth at Rosneft, which will now own all of TNK-BP as well. BP’s announcement Monday noted that Rosneft had 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 joint venture. In 2003, BP invested $8 billion to acquire half the venture. Since then, TNK-BP has paid BP $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 hurriedly left Moscow amid an escalating 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 still have not agreed on a dividend payment for this year.