BP (BP) agreed to sell its 50% stake in Russian joint venture TNK-BP on Monday to state-controlled Rosneft in a two-part deal valued at about $55 billion.

The agreement finally ends a soured relationship with AAR, its joint venture partner in TNK-BP that is operated by a group of Russian billionaires, and allows BP to cozy up to the Russian government that has a tighter grip on the country’s booming oil market.

In the first part of the transaction, BP will sell its stake in TNK-BP to Rosneft, the top oil producing company in Russia, for $17.1 billion in cash and shares valued at about a 12.84% stake in Rosneft.

The British oil company said it intends to use $4.8 billion of the cash proceeds to buy a further 5.66% of Rosneft from the Russian government at an average price of $8 a share, which represents a premium of 12% over Rosneft’s closing price on the Oct. 18 bid date.

Once completed, BP will net about $12.3 billion in cash and acquire an 18.5% stake in Rosneft, bringing its total stake in the oil company to 19.75%. With the new level of Rosneft ownership, BP said it expects to gain two seats on the company’s nine-person board and will be able to account for its share of Rosneft’s earnings, production and reserves on an equity basis.

"Russia is vital to world energy security and will be increasingly significant in years to come,” BP's chairman Carl-Henric Svanberg said in a statement. “TNK-BP has been a good investment and we are now laying a new foundation for our work in Russia.”

The companies have now entered an exclusive 90-day negotiating period and the deal, which remains subject to customary closing conditions, regulatory and anti-trust approvals, is set to close during the first half of 2013.

BP has agreed to not sell any of its shares in Rosneft for at least a year and said it will evaluate how to use the remaining cash proceeds, including through its dividend program or offsetting any dilution to earnings per share related to the TNK-BP sale.

CEO Bob Dudley said BP plans to be “a long term investor” in Rosneft, holding onto at least part of its stake for at least a decade or longer.

"Rosneft is set to be a major player in the global oil industry,” Svanberg said. “This material holding in Rosneft will, we believe, give BP solid returns.”

Shares of BP fell about 1.5% to $42.47 on Monday.

Morgan Stanley (MS) is acting as principal financial advisor to BP, with UBS (UBS) acting as financial advisory and corporate broker.

Follow Jennifer Booton on Twitter at @Jbooton