A group of police officers plotted to assassinate Nelson Mandela at his 1994 presidential inauguration, a court heard.

A homemade gun that was to have been used in the assassination bid from a Pretoria rooftop was found several years later under the desk of a senior police officer in the city, it was alleged. Senior police officers are accused of attempting to cover up the plot.

Details of the plot emerged in the Western Cape High Court this week in a civil case brought by Major General Andre Lincoln.

Lincoln was appointed by Mandela in 1996 to lead an elite investigation unit to probe mafioso Vito Palazzolo. The hand-written note in which Mandela ordered the formation of the unit has been submitted as evidence in the trial.

In the course of his investigation Lincoln claims he uncovered the involvement of senior police officers in the assassination plot, and was framed for links to Palazzolo. He claims that his attempts to investigate the plot were repeatedly blocked.

He was dismissed from the police in 2003, to be reinstated in 2010 after being cleared of involvement with Palazzolo.

He told the court that his unit had reopened an inquiry into "the attempted assassination plot against the president. That investigation was totally covered up ... The handcrafted rifle that was going to be used was hidden under the desk of a senior police officer in Pretoria. We reopened the investigation with lots of resistance."

South Africa's News24 reported that if successful the assassination plot would have sparked an "unprecedented bloodbath" in South Africa, where Mandela, who was released from prison in 1990, won the Nobel Peace Prize for leading efforts to unify the country after decades of apartheid.

The police force was headed at the time by Mandela appointee George Fivaz, and Lincoln said the absorption of Fivaz and other former ANC operatives into the police had caused friction, with the force still dominated by "white Afrikaner men of the old order."

In 2013, a group of white supremacists were jailed for a 2002 plot to assassinate Mandela and reinstate apartheid after seizing power.