Hugh Masekela, a South African trumpeter, singer and activist whose music became symbolic of the country’s anti-apartheid movement, even as he spent three decades in exile, died on Tuesday in Johannesburg. He was 78.

His death was confirmed by Dreamcatcher, a communications agency that represented him.

Mr. Masekela came to the forefront of his country’s music scene in the 1950s, when he became a pioneer of South African jazz as a member of the Jazz Epistles, a bebop sextet that included the pianist Abdullah Ibrahim and other future stars. After a move to the United States in 1960, he won international acclaim and carried the mantle of his country’s freedom struggle.

His biggest hit was “Grazing in the Grass,” a peppy instrumental from 1968 with a twirling trumpet hook and a jangly cowbell rhythm. In the 1980s, as the struggle against apartheid hit a fever pitch, he worked often with fellow expatriate musicians, and with others from different African nations. On songs like “Stimela (Coal Train),” “Mace and Grenades” and the anthem “Mandela (Bring Him Back Home),” he played spiraling, plump-toned trumpet lines and sang of fortitude and resisting oppression in a gravelly tenor, landing somewhere between a storyteller’s incantation and a folk singer’s croon.

In the 1970s and ’80s, he collaborated with musicians across sub-Saharan Africa, constantly expanding his style to accommodate a range of traditions.