It was an outburst that came out of the blue.

In the hours after Donald Trump launched a personal Twitter attack on Justin Trudeau from Air Force One, Canadian officials were at a loss to explain the U.S. president's anger over statements the prime minister made during his news conference to close the G7 summit.

Nothing Trudeau said was new. The Prime Minister's Office later made that point in a statement, adding that Trudeau had made those comments privately to Trump as well.

Trudeau had received polite applause from cabinet ministers and Canadian political staffers when he announced Saturday that the G7 countries had finalized a joint communiqué.

After a tough week and a challenging summit, it was a victory for Trudeau that the leaders had managed to find consensus language on the difficult issue of trade.

The fragile consensus lasted about two hours before it was nuked by a tweet, as Trump made his way to Singapore for the North Korea nuclear summit.

"Based on Justin's false statements at his news conference, and the fact that Canada is charging massive Tariffs to our U.S. farmers, workers and companies, I have instructed our U.S. Reps not to endorse the communiqué as we look at tariffs on automobiles flooding the U.S. Market!," Trump tweeted.

Trump proceeded to blast Trudeau as "meek and mild" and "very dishonest and weak" in a barrage that was sparked by the prime minister's assertion that U.S. tariffs on steel and aluminum were "insulting" and his insistence that Canada would not be pushed around.

Prime Minster Justin Trudeau speaks to reporters at the conclusion of the G7 leaders summit in Charlevoix, Que. 42:20

But a senior Canadian official says the use of the word "insulting" was deliberate and lifted from a conversation with Trump at last year's G7.

During a one-on-one meeting in Taormina, Italy, the two leaders discussed Trump's desire to use tariffs to boost the American steel and aluminum sectors. According to the official, Trump gave assurances that Canada would be spared the hit saying "it would be an insult to Canada" to call them a national security threat.

A lot can change in a year. And once Trump decided to hit Canada with tariffs, Trudeau decided to hit the U.S. airwaves.

The senior official says that before the prime minister appeared on Meet the Press a week ago, he called Trump and told him what he would say. After the appearance was over, Trudeau spoke to Trump again and told him he would keep saying it until the tariffs were lifted.

So the prime minister's comments on Saturday should not have been a surprise to anyone.

But it provoked a reaction that undid hours of overnight diplomacy to reach the fragile and fleeting consensus.

Diplomatic acrobatics

The push for an agreement started on Friday night, as the G7 leaders sat around a campfire in La Malbaie, Que., to watch a performance by the province's world famous Cirque du Soleil.

It was fitting entertainment — because if ever there was a meeting that needed acrobatics and contortions to get to an agreement, it was this one.

Once the performance was over, Trudeau asked the leaders to step inside Le Manoir Richelieu to the room used as the leaders' lounge for this summit. It was an unscheduled meeting to speak candidly on the issues that divided them.

There were deep divisions between the leaders and Trump that made a unanimous communiqué unlikely.

Trump rode into Quebec's Charlevoix region on a torrent of tweets, tariffs and turmoil, putting himself in direct conflict with the United States' historical allies. There was broad disagreement at the G7 table, especially on trade and climate.

The post-campfire chat was the start of an overnight push to find common ground with Trump before he left early Saturday morning. Trump sat at the end of a couch, German Chancellor Angela Merkel to his right. Trudeau sitting to his left in a chair.

Once the leaders finished, their top officials — known as sherpas in summit parlance — worked through the night to finesse the discussions into fine print.

The next morning — after a breakfast event on gender equality — Trudeau asked for another unscheduled leaders' meeting to discuss the communiqué.

Pictures from this private meeting were shared widely on social media by the leaders themselves. Trump sat with his arms crossed at a long rectangular table covered by a white table cloth. The other leaders and their officials stood around the U.S. president in an attempt to knit the G7 back together.

This photo of G7 leaders and advisers at the G7 summit was posted to the Instagram account of German Chancellor Angela Merkel, centre, on Saturday, June 9, 2018 with the description "a spontaneous meeting between two working sessions." (Jesco Denzel/German Federal Government via AP)

The sherpas — fresh off that all-nighter — huddled again to see if the leader-driven interventions would allow for a unanimous statement.

Word of their success started to leak out in tweets and off-the-record comments from G7 officials. But the negotiations were so last-minute that the communiqué still wasn't finalized, formatted and translated when Trudeau announced the agreement at his summit-ending news conference.

Trump 'will continue to say what he says'

It appears to be a consensus that exists on paper and not necessarily in the mind of the U.S. president. While the sherpas were still working — and hours before Trudeau spoke — the president held his own news conference.

Trump told the world that the G7 had failed to change his mind when it came to trade.

"The U.S. has been taken advantage of for decades," the U.S. president said. "We are like the piggybank everybody is robbing."

"It has to stop or we will stop trading with them," Trump warned, adding that nations that retaliated against U.S. tariffs are "making a mistake."

Trump gave a news conference before flying to Singapore to meet with Kim Jong Un. He talked about progress made at the G7 summit, his relationship with the other leaders and his demands for trade. 26:47

The words as written in the communiqué suggested a consensus. But the words spoken by Trump made it plain that the disagreements weren't settled and the looming trade war is still on. His tweets later amplified it.

"The president will continue to say what he says at various occasions," Trudeau said, when asked about Trump's departing words.

"Obviously if the expectation was that a weekend in beautiful Charlevoix, surrounded by lovely people, was going to transform the president's outlook on trade in the world, then we didn't quite perhaps meet that bar."

Canadian officials had been downplaying the importance of a communiqué right up to the point that it was clear there would be one. But even though all seven countries signed the declaration, there are other notable points of disagreement.

The United States is refusing to endorse the section on climate change. The U.S. and Japan have balked at signing onto a plastics charter to curb ocean pollution.

The optimistic take was that the leaders had found some common ground on trade.

That optimism didn't survive a 280-character rant.

The leaders leave Quebec's Charlevoix region with tariffs still in place, retaliation looming and a punishing trade war on the horizon.

From Canada's perspective, NAFTA remains unresolved. There was another vague promise to accelerate talks. But Trudeau and Trump publicly disagreed on the American deal-breaker demand for a sunset clause. And the president's tweet storm took their disagreements into the realm of personal insults.

It's clear this meeting did nothing to move the leaders closer to settling the big economic issues that divide them.

But this appears to be what consensus looks like in the age of Donald Trump.