One famous and often-poached comedy routine of Dick Gregory’s involved his experiences in the US south. “I spent 20 years there one night,” Gregory began. “I walked into this restaurant and this waitress said ‘we don’t serve coloured people here’ and I said ‘that’s all right, I don’t eat coloured people. Bring me a whole fried chicken.’” The joke encapsulates the three careers pursued by Gregory, who has died aged 84 – comedian, political activist and diet expert. That Gregory, like many who fought for social justice in the 1960s, wound up in later life selling himself and his new-age lifestyle, should not detract from the impact he made as a comedian, nor the energy he brought to his activism.

It was Hugh Hefner, founder of Playboy, who in 1961 heard Gregory performing at a black club, and hired him for the Playboy Club in Chicago, thus beginning his breakthrough to a mainstream white audience. Previously, black comedians had played to two distinct markets: they could be as free and risqué as they liked with black audiences on the so-called chitlin’ circuit, but had been confined to supporting roles and stereotypical characters for the larger white audience.

It was Hugh Hefner, founder of Playboy, who in 1961 heard Dick Gregory performing at a black club, and hired him for the Playboy Club in Chicago. Photograph: Michael Ochs Archives/Getty Images

Part of Gregory’s success lay in timing; he fitted perfectly into the satire boom led by Mort Sahl. Gregory was sometimes called the “black Mort Sahl”, though he preferred to think of Sahl as the “white Dick Gregory”. Styles more offbeat than traditional standup became popular, and Gregory’s material was as sophisticated as, say, the quirky routines of Bob Newhart. He was sharp, but could soften his edge too. “Segregation’s not all bad,” he said. “Have you ever heard of a collision where the people in the back of the bus got hurt?”

Along with the equally sharp Godfrey Cambridge and the less political Bill Cosby, Gregory opened the door for older black comics such as Nipsey Russell, Moms Mabley and Redd Foxx, as well as inspiring generations of younger comedians. The line from Gregory to Richard Pryor to Eddie Murphy or Chris Rock is remarkably direct.

Born in St Louis, Missouri, Gregory was raised, with his five siblings, by his mother, Lucille, who worked long hours at menial jobs to support them after they were deserted by their father, Presley. He began developing his comic skills to defuse bullies while working odd jobs to help his mother. A good student, he took up athletics because of the hot showers offered after practice.

Gregory became a talented enough runner to get a scholarship to Southern Illinois University. Having been team captain and class president in high school, he found the small daily reminders of inequality at college an eye-opener. “I had been fighting poverty,” he said, “now I was fighting being a negro.” He set college records as a middle-distance runner, and again used humour to cope by entering campus talent shows. “It was more exhilarating than running,” he recalled. “You could say the funniest thing in the world, but if Whitey has hate, he might not laugh. If you can run, Whitey can hate you all he wants and you’ll still come out the better man.”

He was drafted into the US army in 1954, where a sympathetic commanding officer allowed him to practise his standup. After discharge, he moved to Chicago, working in the post office and performing at night. His track connections led him to rent the Roberts Show Bar for a party to celebrate the Pan American games; the club, which attracted top talent such as Sammy Davis Jr, liked his style as MC and hired him.

After Gregory’s Playboy breakthough, Jack Paar elevated him to network television on The Tonight Show, and he insisted on being interviewed, rather than simply performing his routine and leaving, like other black comics. He made a series of successful LP records, starting with In Living Black and White (1961). In 1964 Gregory published his autobiography, Nigger, written with the journalist Robert Lipsyte. In the foreword, he explained that his mother worried about the title, but he reminded her that “whenever you hear that word, you’ll know they’re advertising my book”. More recently, he decried the use of the euphemistic term “N-word”.

Dick Gregory in 2015. Photograph: Paras Griffin/Getty Images

Already active in civil rights protests, in which he was jailed, beaten and shot, in 1967 Gregory, a chainsmoker and heavy drinker, weighing 288lb, staged a public fast to protest against the Vietnam war. That year, he ran as mayor of Chicago against Richard Daley, who would become the villain at the 1968 Democratic party presidential convention.

After that convention nominated Hubert Humphrey, Gregory ran as a write-in candidate (one whose name does not appear on the ballot paper but who may be named as their choice by voters) for the Freedom and Peace party, with Mark Lane, author of the JFK assassination critique Rush to Judgement, as his running mate. Although he had the support of many students, including me, who felt betrayed when Eugene McCarthy and George McGovern were shoved aside in the wake of Robert Kennedy’s assassination, few of them were old enough to vote. With the black activist Eldridge Cleaver representing the “official” Peace and Freedom party, and the comedian Pat Paulsen’s mock campaign devaluing Gregory’s, he attracted only 47,000 votes, as Richard Nixon won a narrow victory over Humphrey, while the Alabama governor George Wallace gained 9m votes as an independent.

Gregory’s candidacy was enough to put him on Nixon’s enemies list, and make him a target of FBI surveillance. In 1971 he and Lane collaborated on Code Name Zorro (retitled Murder in Memphis), accusing the authorities of a cover-up in the Martin Luther King assassination. He gave up performing in clubs in favour of churches, universities and rallies. His message had expanded to include vegetarianism, specifically to advocate eating only raw fruit and vegetables, and abstinence from drugs. He said the nightclub environment was antithetical to his message and his controversies and unpredictable schedules meant show business work started to dry up.

He returned to the public eye during the 1980 Tehran hostage crisis, when he travelled to Iran to negotiate release of the hostages, then staged a hunger strike. He weighed less than 100lb when he returned to the US. His serial fasting reached its peak with a 40-day fast in support of the singer Michael Jackson when he faced charges of child molestation in 2004. He picketed against FBI headquarters being named after J Edgar Hoover and, in 2004, was arrested outside the Sudanese embassy in Washington while protesting against genocide.

Dick Gregory promoting his Bahamian Diet drink

His activism sometimes seemed at odds with his role as a pitchman for his Bahamian Diet drink and as a diet consultant. In 1988 he was hired to help Walter Hudson, who weighed 1,200lb, lose almost 600lb and squeeze through the doorway of his house. Tabloids and talk shows chronicled every ounce of progress, but afterwards Hudson regained most of the weight, and died of complications from obesity.

In 2000, when Gregory was diagnosed with lymphoma, he treated himself with diet, herbs and what he described as “devices not yet known to the public”, and announced that the cancer had gone into remission. He quipped, “I look at the obituaries every morning, and ain’t nobody listed but you eaters.”

His many books included Defining Moments in Black History: Reading Between the Lies (2017), in the title of which the word “black” was scored out.

He is survived by his wife, Lillian, whom he married in 1959, and 10 children. A son, Richard Jr, died in infancy.

• Richard Claxton Gregory, comedian and campaigner, born 12 October 1932; died 19 August 2017