In June 1979, the Bee Gees were on top of the world. Months before, their “Saturday Night Fever” soundtrack, featuring songs written and/or performed by the Australian trio, had won a Grammy for album of the year. The year before, it spent 24 weeks at No. 1 on the Billboard charts. And now the band was playing 60,000-seat arenas across America.

Disco was king, and the Bee Gees — brothers Barry, Robin and Maurice Gibb, clad in white suits and flashing gold chains — were its ambassadors.

At the start of the tour, Maurice got hold of a T-shirt that made everyone backstage laugh. It read: “Shoot the Bee Gees.”

Six months later, as the tour was winding down, nobody was laughing. The disco craze that had ruled the late ’70s had come to a screeching halt, and the Bee Gees, lords of the airwaves for two years, found themselves banned from the country’s most influential radio stations.

They hadn’t been shot, but they were as good as dead.

“Nobody wanted to touch them,” said Simon Spence, whose new book “Staying Alive: The Disco Inferno of the Bee Gees” (Jawbone Press) chronicles the group’s meteoric rise and spectacular fall.

“What happened to them was unprecedented in popular music.”

The Bee Gees had first come to prominence in 1967 when manager Robert Stigwood, who’d had success overseeing Eric Clapton’s career, positioned the siblings as the next Beatles. With their tight harmonies and telegenic looks, songs such as “To Love Somebody” and “How Can You Mend a Broken Heart” cruised into the top 10.

Still, they weren’t exactly winning over America as the Beatles had. Their album sales were faltering by the mid-1970s. But then Stigwood hit upon a bright idea. He had acquired the film rights to a New York Magazine story called “Tribal Rights of the New Saturday Night,” about working-class kids from Bay Ridge who become stars on the dance floor of 2001 Odyssey, a Brooklyn disco.

The movie — “Saturday Night Fever” — was to star John Travolta, a popular TV actor from the sitcom “Welcome Back, Kotter.”

The Bee Gees, with their exposed hairy chests and high voices, were now the butt of ‘endless comedy sketches.’

The Bee Gees were working on a new album at the time, but Stigwood insisted they scrap it to work on the soundtrack. He effectively pillaged five of their new songs, including “Stayin’ Alive” and “More Than a Woman.”

The Bee Gees weren’t thrilled. In fact, “They didn’t give the tracks much thought or care or attention,” says Spence.

“Saturday Night Fever” opened in theaters Dec. 12, 1977. Between Christmas and New Year’s, 750,000 copies of the soundtrack sold. By January, it was the No. 1 album in America. As a result, by 1978, 200 radio stations in America were devoted to disco.

“We all went a bit crazy,” eldest brother Barry Gibb recalled.

A backlash was inevitable. Steve Dahl, a Chicago radio shock jock who hated disco, kicked it off with a demolition on July 12, 1978, at Comiskey Park: About 10,000 people showed up at the ballpark, many clutching Bee Gees records — which were tossed into a bonfire.

Homophobia fueled much of the hatred. White men between the ages of 18 and 34 who loved rock “felt excluded, even threatened, by the disco scene,” Spence writes. “The phrase ‘disco sucks’ was a clear pejorative term.”

In February 1980, Billboard reported that American radio had adopted a “virtual ban” on disco. Barry called it “evil” and “censorship” — but nobody paid much attention. The Bee Gees, with their exposed hairy chests and high voices, were now the butt of “endless comedy sketches,” Spence writes.

Barry couldn’t understand what had happened: “It was almost like people were angry with us and it was more interesting to make fun of us than to actually try and understand or appreciate what we had done.”

Robin said simply: “The public had OD’d on us.”

Maurice, Robin’s twin, took it the hardest. He’d battled drugs and alcohol for years and now upped the intake. Shortly after the tour ended, he checked into a private London clinic for alcohol abuse. His recovery didn’t last long. In 1981 he was thrown off the Concorde for drunk and disorderly behavior.

Rumors swirled that the Bee Gees were going to break up.

“The exhaustion of being the Bee Gees set in, and we couldn’t see what tomorrow was going to bring,” Barry admitted.

But they made another album, “Living Eyes.” Burned by the backlash, they dropped the disco sound. Barry even lowered his falsetto. The record was a bust, overshadowed by tabloid stories about Robin’s tumultuous relationship with his estranged wife. Convinced she was having an affair with her divorce lawyer, Robin broke into his own home to collect evidence. He was arrested.

Still, Maurice and Robin wanted to keep the Bee Gees going. Only Barry understood their era was over. He said of “Stayin’ Alive”: “We would like to dress it in a white suit and gold chains and set it on fire.”

He persuaded his brothers that they should write songs and produce albums — for other artists. They came up with hits for Barbra Streisand, Dolly Parton and others. Their biggest hit was “Heartbreaker,” which Dionne Warwick took to the top of the charts.

But its success further depressed Maurice.

“I cried my eyes out after we wrote it,” Spence quotes him as saying. “I drove home and thought, ‘We should be doing this one.’ ”

Maurice never kicked his addictions. He died in 2003 from ailments brought on by alcoholism. Robin died in 2012 of colon and liver cancer.

Barry, now 71, is the only Bee Gee left. Two months ago he performed at the Glastonbury Festival in England.

His set list included all the songs from “Saturday Night Fever.” The crowd went wild.