Biden, who has led an international coalition to punish Russian President Vladimir Putin for the near-seven month war in Ukraine, wants South Africa's help in efforts that include forcing Moscow to sell its oil at below-market rates.

After a jovial greeting before the press, the two leaders spoke privately in the Oval Office for more than an hour on topics that included trade, climate and energy, the White House said.

They committed to addressing several of "the world's most urgent challenges over which we both share concern, including the Russia-Ukraine conflict and its negative consequences for food security in Africa," the White House said.

Biden also announced $45 million in funding for an $8.5 multinational venture aimed at accelerating the phasing out of coal-fired power generation in South Africa.

The additional U.S. funding for the Just Energy Transition Partnership comes at time when declining natural gas and oil exports from Russia and Ukraine have boosted South African coal and set back decarbonization goals for one of the world's most carbon-intensive economies.

In recent weeks, Biden and his aides have been ramping up engagements with African countries as they cast a wary eye on investments and diplomacy by rivals Russia and China on the continent.

Ramaphosa has resisted calls to directly criticize Russia, instead opposing the use of force generally. In March, he blamed NATO's eastward expansion for instability and said the conflict should be solved through United Nations mediation rather than Western-led sanctions that hurt "bystander countries."

South Africa was one of 17 African countries to abstain from the U.N. vote condemning Russia's assault.

"Our position on this is respected, it is known and recognized," Ramaphosa told reporters after the meeting. "Clearly the conflict has to be resolved. Our view is that it can best be resolved through dialogue and negotiations."

Ramaphosa's African National Congress (ANC) party, which has governed South Africa since white minority rule ended in 1994, had strong ties to the former Soviet Union, which trained and supported anti-apartheid activists.

However, South Africa still enjoys a high level of diplomatic clout among Russia's rivals in the West relative to its economic size since its peaceful transition to democracy.

Last month, during a visit to South Africa, U.S. Secretary of State Antony Blinken said Washington would not dictate Africa's choices, after pledging to "do things differently," following former President Donald Trump's insulting remarks about African countries.

A bill passed by the U.S. House of Representatives in April would boost U.S. efforts to counter Russian influence in Africa.

"We have expressed our discomfort and our opposition," Ramaphosa said in a video uploaded to Twitter. "We should not be told by anyone who we associate with and we should never be put in positions where we have to choose who our friends are."

Africans often resent being a theater for competition between China, Russia and the Western order. The Ukraine war exacerbated the longstanding rivalry over Africa's natural resources, trade and security ties.

War and inflation have pressured South Africa, where half of the population lived below the poverty line even before the war dried up Russia and Ukraine's grain and fertilizer exports.

Biden is due to host more leaders from the continent in December, when ANC members will also decide whether to keep Ramaphosa as their party leader.

(Reporting by Trevor Hunnicutt in Washington; Additional reporting by Tim Cocks in Johannesburg and Andrea Shalal, Costas Pitas and Kanishka Singh in Washington; Editing by Aurora Ellis and Edwina Gibbs)

By Trevor Hunnicutt