When Ahmed Rabbani ran out of paint to satisfy his artistic yearnings during 20 years of incarceration at Guantanamo Bay, he turned to whatever came to hand -- dirt, coffee grinds and even spices such as turmeric from the prison canteen.

"Through painting, I would feel myself outside Guantanamo," the 53-year-old Pakistani said this week at an exhibition of his work in the port city of Karachi.

"Painting was everything for me there."

Rabbani was detained by Pakistan authorities in September 2002 and handed over to the US Central Intelligence Agency for a bounty of $5,000.

He was "sold" on the basis he was a notorious militant known as Hassan Ghul, but Rabbani always insisted it was a case of mistaken identity.

He was also accused of recruiting his older brother Muhammed into extremist circles.

Both were never charged or faced trial during two decades in detention, and they were only released in February this year.

"The US had paid good money and did not want to have been taken for a ride," Rabbani's lawyer, Clive Stafford Smith, wrote in the exhibition catalogue.

"Something neither he nor I knew until the US Senate published its Rendition Report in 2014 was that Ghul was captured and brought to the same prison -- only to be released back to Pakistan for 'cooperating'.

"While Ghul went back to his terrorist ways and was killed in a drone strike in 2012, Ahmed got a one-way trip to Guantanamo Bay."

- Drawing from coffee, turmeric -

Born in Mecca, Saudi Arabia, where his parents worked, Rabbani moved back to Karachi as a teen and was a taxi driver at the time of his detention.

Fluent in Arabic, he specialised in guiding visitors from the Middle East -- a factor which contributed to him being misidentified.

While imprisoned in Guantanamo Bay, painting became an obsession for Rabbani, although years spent on hunger strike meant he was often too frail to even hold a brush.

If he ran out of materials, he would improvise.

"I would find and turn a piece of discarded or torn clothes into canvas," he said.

"Sometimes I drew from coffee, sometimes from turmeric."

In "The Unforgotten Moon: Liberating Art from Guantanamo Bay", around two dozen pieces Rabbani was allowed to take from prison are on display -- alongside works by local artists who have "re-imagined" paintings that were confiscated.

"He is someone who has lost so much of his life, so to produce the images of this quality is a miracle... it's remarkable," said Natasha Malik, curator and organiser of the exhibition.

"Displayed alongside Ahmed's uncensored artwork, the artists amplify his protest and creative expression, by recreating the work that the public was never meant to see."

Sporting a salt-and-pepper beard and wearing a traditional shalwar kameez and waistcoat, Rabbani was the centre of attention at the exhibition opening.

With a smile and twinkle in his eye, he outlined grand plans for the years ahead.

First up is the publication of a cookery book -- he rekindled a passion for the kitchen while at Guantanamo.

"It will have his memoirs in it -- but in the setting of a cookbook," Stafford Smith told AFP.

Then he wants to open a restaurant based on recipes he learnt while in prison -- hopefully using funds raised from sales of his art.

Depicting his hopes and despair, his artwork is astonishingly accomplished for someone who did just a smattering of art at school.

Some pieces are obvious expressions of yearnings for freedom -- nature seen through narrow openings, birds flying and endless oceans.

Another shows a cage containing bright orange fish -- the colour of overalls Guantanamo prisoners were forced to wear.

"I spent many years in orange," he said.

"I never accepted their laws. I would always break their laws."