LONDON (AP) -- Russian oil giant Rosneft said Monday it is buying TNK-BP, the joint venture between AAR, a group of Russian oil oligarchs, and BP, the British the energy company.

BP said it had agreed to sell its 50 percent stake in TNK-BP to Rosneft for $17.1 billion in cash and a 12.84 percent stake in the Russian oil group.

In Moscow, Rosneft said it had also agreed to buy the other 50 percent in the joint venture from AAR for $28 billion. Rosneft said the deal with AAR is "entirely independent of the transaction with BP."

In its statement, BP said that it would use some of the money from its deal to raise its stake in Rosneft to 19.75 percent.

BP shares were up 1.1 percent to 455 pence following the announcement, while Rosneft shares were up 3 percent.

Russia is an important part of BP's business, accounting for a quarter of its oil production. BP Chief Executive Bob Dudley has looked to the country's vast oil resources as a key ingredient to the company's recovery from the disastrous oil spill in the Gulf of Mexico.

The TNK-BP joint venture has been troublesome for BP. The UK oil group's disputes with its partner — in 2011, it tried to strike a separate partnership with Rosneft to explore for oil beneath the Arctic Ocean, only to be sued by AAR — have alarmed BP's investors and hit its share price.

"BP intends to be a long term investor in Rosneft - an investment which I believe will deliver value for our shareholders over the next decade and beyond," Dudley said.

Rosneft's Chief Executive Igor Sechin said his company "would benefit from BP's experience and its track record of implementing best international practices in Russia."

Rosneft said it would finance the deal with its own cash as well as new borrowings.