President Ramaphosa along with several South African politicians have pledged their solidarity with Palestine.
South Africa's foreign minister said Tuesday she had a phone call with the Hamas leader to discuss humanitarian aid for Palestinians, but denounced allegations of supporting the militants' attack on Israel.
Naledi Pandor said she received a request to call Hamas leader Ismail Haniyeh to discuss humanitarian support.
"Minister Pandor and the Hamas leader discussed how to get the necessary humanitarian aid to Gaza and other parts of the Palestinian Territories," the Department of International Relations and Cooperation (DIRCO) said in a statement.
The ministry condemned allegations in local media of government support for the brutal assault which left more than 1,400 dead, mainly civilians, in Israel.
Israel declared war on Hamas after the Islamist group's fighters broke through the heavily fortified Gaza border on October 7, and also took at least 199 people hostage.
Israel has hit Gaza with air strikes that have killed more than 2,700 people, imposed a crippling siege on the territory and demanded residents in the north of the strip move south ahead of a major urban ground assault.
DIRCO said the claims were "untrue" and "meant to impugn the Minister and the Government of South Africa".
"During the call, and in line with the government's position, Minister Pandor reiterated... solidarity and support for the people of Palestine and expressed sadness and regret for the loss of innocent lives both Palestinians and Israelis".
"We do not have a bilateral relationship with Hamas. We have bilateral ties with the Palestinian Authority," presidential spokesman Vincent Magwenya wrote on X, formerly Twitter.
"Support for the Palestinian struggle against occupation does not equate to support for Hamas" he said.
At the weekend, President Cyril Ramaphosa along with several African National Congress (ANC) officials sporting Palestinian flags and keffiyeh scarves pledged their solidarity with the Palestinians.
"As people and an organisation that has struggled against an oppressive system, of apartheid, we do pledge solidarity with the Palestinians and as the African National Congress we have always pledged our solidarity with them" Ramaphosa said.
Several pro-Palestine and pro-Israel protests have taken place across South Africa.