"We really need to make sure we fully understand one another," Biden said as he welcomed Ramaphosa in the Oval Office. "Our partnership is essential."
Ramaphosa said he sought to work together on security, including in South Africa's troubled neighbor Mozambique, as well as on climate change, a key priority for the Biden administration.
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 visit really is about strengthening the relationship between South Africa and the United States," Ramaphosa said, adding that Washington had a "key role" to play on security across Africa.
But Ramaphosa warned Biden over a piece of legislation that has passed through the US House of Representatives which would require a strategy to counter Moscow's role in Africa.
Ramaphosa said he explained that Africans should not be "punished" for their historic non-aligned position among major powers.
"I think it will harm Africa and marginalize the continent," Ramaphosa told reporters after his meetings.
"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."
The legislation, called the Countering Malign Russian Activities in Africa Act, has yet to clear the Senate and US policymakers stress that it does not in itself lay out any repercussions for African countries.
South Africa's Foreign Minister Naledi Pandor denied being neutral but said "there are reasons for the perspectives that exist and one should never, I think, try to pretend that there aren't histories."
She pointed to the former Soviet Union's championing of anti-apartheid forces compared with periods of Western cooperation with South Africa's former white supremacist regime.
"I think we've been fairly clear, in our view, that war doesn't assist anyone and that we believe the inhumane actions we have seen against the people of Ukraine can't be defended by anybody," she said this week at the Council on Foreign Relations in Washington.
South Africa was one of 17 African countries to abstain from the U.N. vote condemning Russia's assault.
This report was compiled with information from Agence France-Presse and Reuters.