CALGARY - Prime Minister Justin Trudeau launched an impassioned defence for balancing the environment and economy at a raucous town hall in the heart of oil country Tuesday.

A man wearing a shirt with "I Love Oil Sands" written on it and a hat emblazoned with U.S. President Donald Trump's "Make America Great Again" campaign slogan took Trudeau to task for earlier oilsands comments.

At a town hall in Ontario earlier this month, Trudeau was criticized for saying the oilsands would need to be phased out eventually. At the close of a Calgary cabinet retreat earlier Tuesday, he said he misspoke.

The questioner at Tuesday night's gathering accused the prime minister of making inconsistent statements depending on whether he was in eastern or western Canada.

"You're in Alberta right now, sir. You're not in Ottawa," the man shouted. "Yet when you come to Calgary, you tell people you're sorry.

"You are either a liar or you're confused. And I'm beginning to think it's both."

The man asked Trudeau whether he would take back the remark, prompting cheers from some in the crowd of more than 1,700.

Trudeau replied that he has been consistent in his oilsands message.

"I have repeatedly said that yes, the responsibility of any Canadian prime minister is to get our resources to market and yes, that includes our oilsands fossil fuels," he said.

"I've also said that we need to do that in a responsible, sustainable way - that you cannot separate what's good for the environment and what's good for the economy."

Trudeau said even former Conservative prime minister Stephen Harper recognized the world would have to get off fossil fuels eventually.

He asked the crowd of mostly students to put up their hands if they think climate change is real and virtually everyone did.

A few other questions at the town hall touched on the economic pain Alberta has been going through in recent years as a result of low oil prices.

The unemployment rate in Alberta, where the economy largely centres on the oil and gas sector, was at 8.5 per cent in December, higher than the national rate of 6.9 per cent. Tens of thousands of people have lost their jobs over the past few years.

Trudeau was also grilled on Canada's future peacekeeping role, trade, violence against indigenous women and strategies to tackle poverty.

A handful of hecklers interrupted Trudeau throughout the event at the University of Calgary. Trudeau responded by drawing on his past life as a teacher, telling one man he didn't want to reward bad behaviour by giving it too much attention.

Trudeau and the federal cabinet wrapped up a two-day retreat in Calgary earlier Tuesday that was focused largely on how to deal with an unpredictable new administration south of the border.