THE best way to affirm and celebrate the life of Nelson Mandela is to understand and participate in contemporary liberation struggles.

Mandela gave inspiring and dignified leadership to struggles against racism and apartheid; but he also played a central role in creating the new South Africa as the 'Rainbow Nation', with the world's first constitutional guarantee of equal rights with respect to sexual orientation - and the world still has much to learn from this.

In a context where 78 states still criminalise same-sex sexual behaviour, we need to understand the global struggle for decriminalisation and human rights, with respect to sexual orientation as an anti-apartheid struggle of our time.

Nelson Mandela was a leader who showed us the way in such liberation struggles - not only through his widely cited virtues of courage and determination, but also - less apparently - as a political strategist forging alliances across movements, and through his characteristic kindness and empathy.

Mandela was to become critical in the African National Congress's move to endorse human rights with respect to sexual orientation. While engaged in the anti-apartheid struggle, Mandela got to know Cecil Williams, a white gay theatre director and communist - as recorded in the 1999 documentary film The Man Who Drove With Mandela. Disguised as a chauffeur, Mandela would drive Williams around South Africa - sometimes in a limousine - and thus was able to travel covertly and attend political meetings.

The experience of getting to know a white gay man who was committed to solidarity across struggles influenced Mandela's views. Similar experiences occurred later for ANC activists exiled in London in the 1980s. Hence when in 1990 the African National Congress began its international consultation on the content of a draft Bill of Rights, sexual orientation was allowed onto the human rights agenda.

This resulted in 'sexual orientation' being included in the interim constitution of 1994. This process is described in the recent book Human Rights, Sexual Orientation and Gender Identity in The Commonwealth: Struggles for Decriminalisation and Change, compiling work from activists and academics worldwide (available free online at: http://commonwealth.sas.ac.uk/publications/house-publications/lgbt-rights-commonwealth).

Several chapters highlight the groundbreaking nature of the South African case. As Corinne Lennox and I comment as editors: "South Africa shines as a beacon of hope in many respects - particularly relative to other states in Africa."

South Africa sets a crucial example in the Commonwealth, where due to the British Empire's legacies, 41 of 53 states still criminalise same-sex sexual acts.

Crucially when President Mandela came into office in 1994 he appointed members of the new Constitutional Court including Albie Sachs, who had successfully argued for the inclusion of sexual orientation in the Bill of Rights.

This led to the courts ruling for comprehensive legal equality: first on employment discrimination in 1996, decriminalisation of same-sex sexual acts in 1998, equal age of consent in 2007, together with same-sex adoption, and marriage in 2006. Although current President Jacob Zuma might turn back the clock, South Africa remains unique in Africa with respect to same-sex marriage. But looking beyond the marriage issue, thinking about the South African struggle also helps us see how sexual apartheid is still practised - in everyday life, in churches and in families.

There are many things we need to learn from Nelson Mandela and the ANC. Above all, that liberation struggles are not over - they are still ongoing and we need to fight them.

Matthew Waites is Senior Lecturer in Sociology in the School of Social and Political Sciences at the University of Glasgow