Rosneft has taken over TNK-BP in a $55bn (£36bn) deal that will make the Russian state-owned oil company by far the world's largest listed oil producer.

The deal, which was sealed at a meeting with the Russian president, Vladimir Putin, at his mansion on the outskirts of Moscow on Thursday, will see BP collect $16.7bn in cash and a 12.5% stake in Rosneft in return for its 50% stake in the TNK-BP venture. The deal takes BP's stake in Rosneft to 19.75%, and BP will get two seats on the Russian company's board.

BP's partners in the TNK-BP joint venture – billionaires Mikhail Fridman, German Khan, Viktor Vekselberg and Len Blavatnik, known collectively as AAR – will collect $27.7bn for their stake.

Bob Dudley, BP's chief executive, said it was a "historic day for BP in Russia".

"BP has invested in Russia for more than 20 years and for a decade we have been Russia's largest foreign investor through our involvement with TNK-BP," he said. "We aim to continue that success with today's transaction, which increases our stake in Rosneft and gives us a wonderful opportunity to forge a new partnership with a great Russian oil company."

Igor Sechin, Rosneft's chief executive and a long-serving ally of Putin, said: "We welcome BP as the major shareholder of Rosneft, which will take part in shaping the company's strategy. We are glad that BP has made a decision to remain one of the biggest investors in the Russian economy, thus admitting vast prospects of Russia's oil and gas industry and Rosneft's big potential."

The deal is the biggest takeover in Russian history, and will increase Rosneft's daily oil production to 4m barrels a day – more than the daily output of Canada or Iraq. The deal brings an end to BP's troublesome relationship with the billionaires, which forced Dudley, BP's chief executive, to resign as head of the venture and flee Russia during a bitter row in 2008.