Mr Mandela, then South Africa's most wanted man, pretended to be Cecil Williams's chauffeur. They were arrested in 1962.
Although Williams was released and left South Africa, his opposition to apartheid inspired some of the world's most liberal laws on homosexuality, introduced when Mr Mandela came to power.
Yet Williams's name was virtually unknown outside a small band of African National Congress and Communist activists. His role was rediscovered when Albie Sachs, a former anti-apartheid activist who is now a judge, paid tribute to him at a rally in 1995.
Mark Gevisser, a South African journalist and gay rights campaigner, began researching Williams's life. A British production company took up the story for a film, The Man Who Drove With Mandela, which is being shown to potential distributors at the Cannes festival.
In the 82-minute film, to be screened at the ICA in London and then across Britain, archive footage of South Africa is cut with interviews with Mr Mandela and other campaigners. Corin Redgrave plays Williams.
Williams was born in Cornwall in 1906 and moved to Johannesburg to teach in 1928. He ran the anti-fascist Springbok Legion, and produced plays using black and white performers. Actors such as Danny Kaye and Laurence Olivier were guests at his parties. He was beaten up for being gay at a time when homosexuality was taboo.
Lionel Bernstein, who faced treason charges with Mr Mandela at the Rivonia trial, and his wife Hilda, were friends of Williams. The Bernsteins remember him as friendly and popular. Mrs Bernstein, 84, said Mr Mandela's "job" as Williams's chauffeur was known only to "a sect in a minority of the minority".
Yet Williams recklessly, if generously, shared the driving as they smuggled Mr Mandela back into the country from military training in Ethiopia. They were caught on 5 August 1962.
"It was a very important moment," Mr Bernstein, 70, said. "Mandela was the commander-in-chief of the guerrilla armed movement - he was the most wanted man in the country."
After the arrests, Williams was quickly released, but banning orders prevented him from meeting others and working. He left South Africa and died in Britain in 1979.
Kevin Eisenstadt, of the 8th May Group of gay rights supporters in Britain, named after the day in 1996 when South Africa became the first country to enshrine gay rights in its constitution, said they were pleased Williams was being recognised.
The group has organised a benefit performance of the film at the ICA on 24 May to raise money for lesbian and gay organisations in South Africa.Reuse content