Jacob Zuma will hold talks with Gordon Brown on Thursday
The Queen has praised South Africa's journey of "democratic renewal" at a state banquet for President Jacob Zuma.
She told guests at Buckingham Palace that, since Nelson Mandela was freed 20 years ago, the country had achieved the mammoth task of transforming itself.
Mr Zuma, who is on a three-day state visit to the UK, said Britain had helped "free" his country.
Gordon Brown missed Prime Minister's Questions to take part in the welcoming ceremony on Horse Guards Parade.
The monarch addressed Mr Zuma at the palace's ballroom, along with 170 guests including Mr Brown, senior royals and cabinet ministers.
She said: "Twenty years ago last month Nelson Mandela was released from prison in South Africa heralding an extraordinary process of liberation and democratic renewal.
"The task was daunting in its scale and ambition but was achieved through a deliberate and courageous effort of reconciliation and peaceful resolution of differences."
Mr Zuma later acknowledged that problems still existed in his nation.
"We still have a lot of work to do to create the type of society where all South Africans live in prosperity, with access to basic quality services such as health, education, housing, decent jobs," he said.
Earlier, the Queen had formally greeted her guest on Horse Guards Parade, where Mr Zuma reviewed a guard of honour with Prince Philip.
The president and his wife, Thobeka Madiba Zuma, then joined a carriage procession to the palace.
After lunch Mr Zuma presented the Queen with a chess set, only to discover predecessor Nelson Mandela had beaten him to it by giving a similar gift to the Duke of Edinburgh years before.
Mr Zuma also gave the monarch an Ardmore ceramic ornamental dish featuring cheetah and palm decorations.
In return, the Queen gave him a mounted bronze stag and a 1930s book called Hunting And Stalking Deer by Lionel Edwards and Harold Frank Wallace.
The Queen made Mr Zuma an honorary Knight Grand Cross of the Order of the Bath, and in return was given the Order of the Companions of OR Tambo gold class.
It is one of South Africa's highest national honours, given to foreign heads of state and government for friendship shown.
BBC's Mike Wooldridge, Buckingham Palace
President Jacob Zuma and the newest of his three current wives, Thobeka Madiba Zuma, entered the gates of Buckingham Palace amid all the pomp and splendour of the carriage procession that marks the formal start of state visits.
Onlookers lined the Mall despite the stiff breeze.
But if the traditional rituals of such visits are being observed, President Zuma's visit is also distinctive in various ways - not least because on Thursday he will be taking a penalty at Wembley Stadium.
It is symbolic, of course, but will undoubtedly bring yet more attention to South Africa's hosting of this year's World Cup.
In return he will be given a presentation on England's bid to host the 2018 World Cup. With the Olympic park in east London on President Zuma's itinerary too, sport looks set to play a bigger part in this state visit than perhaps any other.
The president also visited the former home of anti-apartheid politician Oliver Tambo in Muswell Hill, north London, and met Conservative leader David Cameron and Nick Clegg, leader of the Liberal Democrats, at Buckingham Palace.
BBC world affairs correspondent Peter Biles says Mr Zuma - a polygamist who has married at least five times - is renowned for his charm.
However, he said officials were nervous before the visit after the president provoked criticism by acknowledging he had fathered a child, his 20th, with the daughter of one of South Africa's leading football officials.
Mr Zuma has previously faced corruption charges and has been acquitted of rape.
Gordon Brown will hold talks with the president on Thursday with the continuing political turmoil in Zimbabwe, climate change and the global economy on the agenda.
The leaders are also expected to discuss football's World Cup, which South Africa is hosting this summer and England hopes to stage in 2018.
The presidential couple will visit the Olympic Park in Stratford, east London, before Mr Zuma will give a speech during a banquet at the Guildhall hosted by the Lord Mayor of London.
On Friday, Mr Zuma will formally say goodbye to the Queen before visiting the Prince of Wales at Clarence House.