The rock concert did not begin with a rock song. Instead, it started with flag-waving fans breaking into a national anthem, "O Canada."

The impromptu tribute by an emotional sold-out crowd that included Prime Minister Justin Trudeau began what was expected to be the final Saturday performance by the Tragically Hip, a group known as Canada's Band, and lead singer and songwriter Gord Downie, dubbed Canada's unofficial poet laureate.

Downie has been diagnosed with terminal brain cancer, and fans across Canada and abroad gathered at viewing parties to tune in and bid him farewell.

The bluesy rock band is better known as The Hip, and Downie is known for penning paeans to Canadian life: about hockey and desolate small towns, about literature and the French explorer who named Canada. Being so defiantly Canadian might be one reason why The Hip sent nine of its 13 albums to No. 1 in Canada, but none above the top 100 in the U.S.

After spending three decades together, The Hip returned on Saturday night to where they began as a college rock band, the Lake Ontario city of Kingston. Those who couldn't get into the Rogers K-Rock Centre massed nearby to watch on a giant screen.

While the band was careful not to declare that its now-concluded 15-show "Man Machine Poem" tour would be its last, the concert had an aura that was both celebratory and somber.

Despite being diagnosed with glioblastoma, the most aggressive cancerous brain tumor, an energetic Downie was in fine form as he and his bandmates played an epic 30-song set, punctuated by three encores.

Trudeau, on learning of Downie's diagnosis in May, tweeted that the singer "has been writing Canada's soundtrack for more than 30 years." On Saturday, the prime minister's official photographer tweeted a photo of Trudeau, 44, and Downie, 52, embracing before the show.

Downie acknowledged Trudeau from the stage. The singer called on the prime minister to take action on behalf of Canada's indigenous people, and then said he expected Trudeau would have plenty of time to do it.

"He's going to be looking good for about at least 12 more years. I don't know if they let you go beyond that. But he'll do it," Downie told concertgoers between songs.

Trudeau could be seen in the audience nodding and mouthing "thank you."

Trudeau reminisced in an interview with the Canadian Broadcasting Corp. about how he enjoyed the band's music during high school and college, and said the band remains uniquely Canadian.

On Twitter, the prime minister said: "On behalf of Canadians, I thank Gord Downie and the Hip for their decades of service to Canadian music. Forever in our hearts and playlists."

While The Hip became one of Canada's most beloved rock bands, lasting success in the U.S. was elusive - outside of border cities like Buffalo, New York, where viewing parties of the concert's Canadian broadcast were also held.

In Rio, the Canada Olympic House hosted a party for Canadian athletes who wore their red team jackets.

Downie, who started the show wearing a metallic silver suit and hat with a "Jaws" T-shirt underneath, hugged and kissed his bandmates - guitarists Rob Baker and Paul Langlois, bassist Gord Sinclair and drummer Johnny Fay. They opened with four songs from their 1992 breakthrough album "Fully Completely": "50 Mission Cap," Courage," ''Wheat Kings" and "At the Hundredth Meridian."

The Hip then segued into songs from their last album, "Man Machine Poem," before running through tracks from "Music @ Work," ''Road Apples," ''Phantom Power," ''Up To Here," ''Day For Night" and "Trouble at the Henhouse."

The band's biggest hit closed the show, "Ahead By A Century."

Downie gestured as if he was sketching a portrait of the teary audience as the band played the son's final notes.

They then embraced, stood arm-in-arm as the crowd roared, and walked off stage.

Before performing one song, Downie seemed to reference the outpouring of support from fans since his diagnosis.

"Thank you, people, for keeping me pushing and keeping me pushing," he said, which prompted a "Gordie!" chant from the audience.

After it ended, Toronto broadcaster and writer Alan Cross tweeted: "We will talk about this show in hushed tones for years to come. #TragicallyHip"