Justin Trudeau encouraged Canadians to stay angry Wednesday about the $10.5 million payout to Omar Khadr — so it will be a reminder not to have another case like that happen again.

The prime minister, in a town hall meeting at McMaster University, responded to a heckler who shouted at him from the top of the bleachers. It was an interruption in an otherwise civil town hall meeting with about 1,900 attendees where Trudeau fielded more than a dozen questions from students and community members.

Trudeau is an embarrassment, the woman shouted, for opening borders, and for agreeing to pay Khadr.

"I hate as a teacher to reward bad behaviour," Trudeau told the shouting woman during the hour-long session in the packed auditorium.

"I want all of you to continue to be angry and frustrated that a Canadian government had to make that settlement," he said.

Prime Minister Justin Trudeau takes questions at a town hall at McMaster University in Hamilton 1:06:45

"Take it as a lesson that in the future. No Canadian government should ever think it's OK to allow a Canadian, no matter how unpopular they may be, to be tortured. That is not how we do things in Canada."

The answer got a standing ovation in Hamilton. But the settlement has been a divisive issue in Canada since news of it broke last summer.

The Toronto-born Khadr moved to the Middle East when he was 10. His father was a money man for Osama Bin Laden and encouraged his children to support al-Qaeda.

The Prime Minister held his second town hall of the year in Hamilton 1:44

In 2002, American soldiers captured a then-15-year-old Khadr in a firefight at a suspected al-Qaeda compound. U.S. Sgt. Christopher Speer died as a result.

Khadr was held and tortured for 10 years at prisons in Afghanistan and Guantanamo Bay before he pleaded guilty to five war-time crimes. He later said he did so under duress.

​The Khadr case was also a fraught subject at a Sackville, N.S. town hall this week. Both are part of Trudeau's six-city tour.

Justin Trudeau spoke to about 1,900 people in a McMaster University gymnasium. (David Donnelly/CBC)

Other Hamilton subjects included the return of ISIS soldiers and the legalization of marijuana.

Tim Gavin of Hamilton said security at McMaster wasn't very tight, so he wondered how Trudeau could keep Canada safe. Trudeau said he relies on advice from security and intelligence agencies.

"We are very alert and responsible for keeping Canadians safe, keeping our communities safe," he said. "It's something we will never compromise on. I can assure you, sir, you are very safe here in this room right now."

As for marijuana, James Lloyd, owner of Where Heads Meet, brought Trudeau a pair of shoes depicting a caricature of the prime minister smoking a joint.

Despite Lloyd's frantic waving, Trudeau didn't choose him during the question period. Lloyd gave the shoes to Trudeau's handlers.

"I figured it was only a shot anyway," he said.

A woman shouted questions at the prime minister about the payment to Omar Khadr. (David Donnelly/CBC)

As for the town hall, "I'm hearing reports saying there was a lot of hecklers. In my mind, there were a couple thousand people there, there were only a few hecklers. I thought he handled it well."

The Prime Minster is in Hamilton today to discuss local issues facing our community. On the campaign trail he told Hamiltonian's that he would protect workers’ pensions, but since taking office all we have heard is silence. <a href="https://twitter.com/hashtag/EndPensionTheft?src=hash&ref_src=twsrc%5Etfw">#EndPensionTheft</a> <a href="https://t.co/lE4pki70BR">pic.twitter.com/lE4pki70BR</a> —@sduvall07

Munera Karim, a McMaster social sciences student, wanted to know more about the government's plans to relieve student debt. None of the questions addressed that, but "the issues he did talk about, he tackled them."

"I was surprised that people didn't get kicked out," she said of the hecklers. "I was surprised he actually listened to them and answered their questions."

Trudeau is expected to visit London, Ont., Quebec City, Winnipeg and Edmonton this month.