Hugh Masekela, the legendary South African jazz musician and anti-apartheid activist, has died after a decade-long fight with cancer. He was 78.

Often called the "Father of South African jazz," Masekela died in Johannesburg after what his family said Tuesday was a "protracted and courageous battle with prostate cancer."

Masekela was a rare artist who succeeded in fusing politics with his music, making his songs and performances compelling and timeless.

Trumpeter, singer and composer Masekela, affectionately known locally as Bra Hugh, started playing the horn at 14. He quickly became an integral part of the 1950s jazz scene in Johannesburg as a member of the band the Jazz Epistles and a member of the orchestra in the groundbreaking jazz opera King Kong.

In the 1960s he went into exile in the United Kingdom and the United States, using his music to spread awareness about South Africa's oppressive system of white-minority rule. He scored an international No. 1 hit in 1968 with Grazing In The Grass.

Obit Makeba

Masekela, singer and ex-wife Mariam Makeba, then African National Congress President Nelson Mandela and Paul Simon, left to right, at a 1992 event in Johannesburg. Masekela was also known as an anti-apartheid activist and his music crossed many genres. (Adil Bradlow/Associated Press)

Masekela spent time in both New York and Los Angeles, performing at the 1967 Monterey Pop Festival with some of the era's most iconic musicians. He collaborated with many musicians including Herb Alpert and the Byrds on their song So You Want to Be a Rock 'n' Roll Star?.

In the 1980s, Masekela appeared with Paul Simon and several other South African musicians as part of the Graceland album tour.

Many of his compositions were about the struggle for majority rule and full democratic rights in South Africa. Masekela's catchy upbeat 1987 song Bring Him Back Home calling for Nelson Mandela's release from prison became an international anthem for the anti-apartheid movement.

He was married to South African singer and activist Miriam Makeba for two years in the mid-1960s. They performed together in 1988 at a concert to raise consciousness for Mandela's release.

"Hugh's global and activist contribution to and participation in the areas of music, theatre, and the arts in general is contained in the minds and memory of millions across six continents," the family statement read.

Carried the 'torch of freedom': President Zuma

Masekela returned to South Africa in 1990 after Mandela was freed and the African National Congress party was unbanned. He released more than 40 albums, and toured in South Africa and internationally until late last year.

Sal Masekela, Masekela's son who is also a musician, wrote in a statement that it was "difficult to comprehend that this moment is real," recalling his father's performances in New York when he would "steal the hearts and souls of innocents with a musical storytelling all his own."

"My biggest obsession is to show Africans and the world who the people of Africa really are," Hugh Masekela is quoted as saying on his official website.

In October last year, Masekela issued a statement that he had been fighting prostate cancer since 2008 and would have to cancel his professional commitments to focus on his health. He said he started treatment after doctors found a "small `speck"' on his bladder, and had surgery in March 2016 after the cancer spread.

Masekela also said he felt an "imbalance" and had an eye problem after a fall in April in Morocco in which he sprained his shoulder. He said another tumour was then discovered and he had surgery.

"I'm in a good space, as I battle this stealthy disease, and I urge all men to have regular tests to check your own condition," his statement said, asking the media for privacy.

Masekela supported many charities and was a director of the Lunchbox Fund, a non-profit organization to provide daily meals to students in Soweto township.

Condolences from fans poured out Tuesday on social media paying tribute to the influential musician's career.

"A baobob tree has fallen," Nathi Mthethwa, South Africa's minister for arts and culture, wrote on Twitter. "The nation has lost a one of a kind musician . We can safely say Bra Hugh was one of the great architects of Afro-Jazz and he uplifted the soul of our nation through his timeless music."

South African President Jacob Zuma expressed his condolences, saying Masekela "kept the torch of freedom alive globally, fighting apartheid through his music and mobilizing international support ... His contribution to the struggle for liberation will never be forgotten."

UN Secretary General Antonio Guterres "recognizes the historical role that he played during the fight against apartheid and the fight for freedom and human rights after the fall of apartheid," UN spokesman Stephane Dujarric said. "He was a global cultural icon that will be missed by people all over the world."

Masekela inspired generations of musicians in jazz and beyond and collaborated in recent years with South African house music DJ Black Coffee, who tweeted Tuesday: "I have no words."

As well as musicians, Kenyan President Uhuru Kenyatta and British Oppositon Leader Jeremy Corbyn also paid tribute to Masekela on social media.

Kenyatta wrote of Masekela: "His music then was the music of a free Africa: full of anger at injustice; confident that one day these injustices would be overcome."

With files from CBC News