Canada will contribute $50 million to a global charity for children's education, Prime Minister Justin Trudeau tweeted to comedian Trevor Noah, a pledge that quickly drew criticism both for its content and its form.

Celebrities gathered in Johannesburg on Sunday for the Global Citizen Festival: Mandela 100, a charity concert honouring Nelson Mandela a century after he was born.

Trudeau tweeted to Noah, who is hosting the festival, that Canada would give the money to Education Cannot Wait, an organization that funds education for children affected by conflicts, natural disasters and other crises.

Global Citizen is an organization that wants to end extreme poverty by 2030. Its Mandela 100 campaign sought to bring in $1 billion US in donations, and Global Citizen tweeted that the campaign surpassed that goal, bringing in over $7 billion.

"Hey @Trevornoah - thanks for everything you're doing to celebrate Nelson Mandela's legacy at the @GlblCtzn festival. Sorry I can't be with you - but how about Canada pledges $50M to @EduCannotWait to support education for women & girls around the world? Work for you? Let's do it," Trudeau tweeted to the South African comedian and The Daily Show host.

Noah said "This is amazing!" as Trudeau's tweet was shown on a big screen at the concert.

Hey <a href="https://twitter.com/Trevornoah?ref_src=twsrc%5Etfw">@Trevornoah</a> - thanks for everything you’re doing to celebrate Nelson Mandela’s legacy at the <a href="https://twitter.com/GlblCtzn?ref_src=twsrc%5Etfw">@GlblCtzn</a> festival. Sorry I can’t be with you - but how about Canada pledges $50M to <a href="https://twitter.com/EduCannotWait?ref_src=twsrc%5Etfw">@EduCannotWait</a> to support education for women & girls around the world? Work for you? Let’s do it. —@JustinTrudeau

But back in Canada, critics were less enthusiastic. Conservative Leader Andrew Scheer accused Trudeau of pledging $50 million in a tweet to impress a TV personality.

"Taxpayers need a defender not somebody who throws their money around to be popular with celebrities," Scheer tweeted.

'Tone deaf' tweet says Rempel

Similarly, Conservative MP Michelle Rempel tweeted that Trudeau's message was "tone deaf" and also accused him of trying to get noticed by a TV star, and said the money had not been budgeted for.

Louis Belanger, director of communications for Canadian International Development Minister Marie-Claude Bibeau, said the $50 million is part of $400 million in aid previously announced during the G7 Summit in Charlevoix near Quebec City, in June.

Belanger said Education Cannot Wait is one of the only funds that specifically helps girls' education in places such as refugee camps and war zones.

"This is the type of funding that we had our eye on since we announced it in Quebec City," he said.

Pledging $50 million in a tweet to impress a TV personality? <br><br>Taxpayers need a defender not somebody who throws their money around to be popular with celebrities. <br><br>This is how deficits become massive and permanent. <a href="https://t.co/lBdAtzH0eX">https://t.co/lBdAtzH0eX</a> —@AndrewScheer

Belanger said the decision to announce the $50 million was made three weeks ago, but officials had been talking about giving to Education Cannot Wait for months.

He said the organization operates in Jordan, Lebanon and South Sudan, and in camps where people have been displaced by the west African terrorist group Boko Haram, for example.

"We think it's important for girls to continue their education and that's why we're moving forward," he said.

Trudeau's principal secretary, Gerald Butts, took to Twitter to defend the move.

"This money is going to educate women and girls in the developing world, in commemoration of Nelson Mandela's 100th birthday," he tweeted, adding, "And the Leader of the Conservative Party of Canada's reaction..." and included a link to Scheer's tweet.

Toronto-based lawyer and former Liberal staffer Warren Kinsella tweeted that Education Cannot Wait is a worthy cause, but called Trudeau's tweet an "appalling" way for the decision to be communicated, "to a American-based TV host, no less."