The oil giant had come under pressure from the UK government to make the move since Thursday's invasion.
It has held the shareholding in the Russian company since 2013.
BP chief executive Bernard Looney has resigned "with immediate effect" from the Rosneft board, as has fellow BP-nominated director Bob Dudley.
Rosneft said thirty years of successful cooperation had been ruined and blamed BP's decision on "unprecedented political pressure", according to reports from Russian news agencies.
Mr Looney had been on the Rosneft board since 2020, alongside its chairman Igor Sechin, who is a close friend and ally of Russian President Vladimir Putin.
The PA News agency reported Mr Looney was in Russia as recently as October, when he appeared on a panel with Mr Putin, which he later described as a "privilege".
Business Secretary Kwasi Kwarteng spoke to the BP boss on Friday and left him in "no doubt about the seriousness of government concerns about BP's overexposure to Russian interests" according to an official.
BP chairman Helge Lund said that, while BP had operated in Russia for more than 30 years and had "brilliant Russian colleagues", Russia's attack on Ukraine was "having tragic consequences across the region" and represented a fundamental change.
"It has led the BP board to conclude, after a thorough process, that our involvement with Rosneft, a state-owned enterprise, simply cannot continue."
BP's share in Russian state oil giant Rosneft has long felt uncomfortable; this week under heavy political pressure it became untenable.
The chairman of Rosneft, Igor Sechin, is a close ally of President Putin. Rosneft supplies fuel to the Russian army.
Immediately offloading the stake to a potentially inappropriate buyer was not an option.
The company has decided to "divest" - meaning it will sever its financial ties with Rosneft, stop taking a dividend and step back from its two seats on the board.
Company officials say it is too soon to say exactly how this stake will be disposed of.
It could potentially be seized, or sold.
It will mean a significant financial hit, but a price BP had little choice but to pay.
Mr Looney said that he had been "deeply shocked and saddened" by the situation in Ukraine and it had caused BP to fundamentally rethink its position with Rosneft.
"I am convinced that the decisions we have taken as a board are not only the right thing to do, but are also in the long-term interests of BP," he said.
Mr Kwarteng welcomed the move, saying: "Russia's unprovoked invasion of Ukraine must be a wake-up call for British businesses with commercial interests in Putin's Russia."
BP's latest annual results, published two weeks ago, revealed Rosneft accounted for $2.7bn (£2bn) of its profits, about a fifth of its total.
The multinational, which has its headquarters in London, admitted last year that sanctions on Russia could be problematic for its business and the relinquishing of the Rosneft stake comes after western countries imposed a series of economic sanctions on Russia - including several banks being excluded from the Swift international payment system.
BP said it is too early to say how or to whom its stake in Rosneft will be offloaded. The firm will pay a $11bn charge when it writes off foreign exchange losses that have accumulated over the last few years and another charge relating to the value of its stake.
Rosneft has been under sanctions from the US and EU since Russia annexed Crimea in 2014.
Norway's $1.3 trillion (£970bn) sovereign wealth fund, which is the world's largest, also announced it would freeze and divest its Russian assets on Sunday.
"We have decided to freeze the fund's investments and have begun a process of selling out," Norwegian Prime Minister Jonas Gahr Stoere said.
The fund's Russian assets were worth $2.83bn (£2.11bn) at the end of 2021. It is the fourth largest shareholder in Russian bank Sberbank and has stakes in Russian energy firms Gazprom and Lukoil.
Oil prices surged past $100 (£74) a barrel to hit their highest level for more than seven years after Russia launched its invasion of Ukraine.
The shipping firms FedEx and UPS have also suspended all their services in and out of Russia. United Parcel Service Inc. (UPS) said that packages in transit to Ukraine and Russia will be returned to their senders for no additional cost where possible.