(Daron Taylor/The Washington Post)

The pressure on President Trump to remain in the Paris climate accord came from all sides.

Silicon Valley titans, such as Apple chief executive Tim Cook and Tesla chief executive Elon Musk, contacted the White House directly, making clear just how seriously they viewed the issue of climate change — and how important it was to them that the president not withdraw from the international pact.

European leaders, including French President Emmanuel Macron and German Chancellor Angela Merkel, used a private summit of the Group of Seven world powers to repeatedly and urgently prod Trump to stay true to the climate deal.

And Ivanka Trump, the president’s daughter, reached out to chief executives and urged them to call her father to make their pro-business case for staying in the accord.

She even personally appealed to Andrew Liveris, the head of Dow Chemical, asking him to spearhead a letter with other CEOs — which ultimately ran as a full-page advertisement in the Wall Street Journal in May — directly appealing to Trump to stay in the agreement, according to a person familiar with the effort.

But in the end, it was not enough.

On Thursday, in a Rose Garden ceremony, the president announced his plan to withdraw the United States from the Paris climate accord.

Trump had never liked the Paris accord. He viewed it as a “bad deal” and during the campaign had promised his base he would “cancel” the climate pact that he believed was hurting American workers.

His final, deliberative verdict was the same as his initial, gut-level one, according to this account of Trump’s decision-making process, which is based on interviews Thursday with more than a dozen administration officials, Trump confidants, Republican operatives and European diplomats. Even so, the president listened and moderated months of often heated, and at times downright contentious, discussions among his own advisers, as well as scores of outsiders.

All but two countries are in the Paris climate agreement. The U.S. could be the third.

“He’s stayed where he’s always been, and not for a lack of trying by those who have an opposite opinion,” said Kellyanne Conway, counselor to the president. “He started with a conclusion, and the evidence brought him to the same conclusion.”

Nonetheless, the debate over what Trump should ultimately do — stay in the deal to push for changes or fully pull out — roiled the administration.

The fight pitted Environmental Protection Agency Administrator Scott Pruitt, chief strategist Stephen K. Bannon and White House Counsel Don McGahn — who all pushed for a total withdrawal — against Ivanka Trump, economic chief Gary Cohn and Secretary of State Rex Tillerson — who argued that the president would have more leverage by remaining an active participant in the climate deal.

During meetings with the president, Bannon, Pruitt and their allies came armed with reams of documents filled with numbers and statistics showing what they said would be the negative effects on the U.S. economy if the United States remained in the climate deal. They were, in the words of one Republican in frequent contact with the White House, “ready to go to trial.”

“They were presenting facts and figures,” Conway said. “They were really important. That was the evidentiary case.”

Some of those opposed to pulling out of the pact, however, said that much of the data the other side presented was either erroneous, scientifically dubious, misleading or out of date.

The Paris pact was a particular passion for Bannon, who spent the past two weeks consumed by the climate deal, including working feverishly from the West Wing after returning early from Trump’s foreign trip, according to two White House officials familiar with the discussions. He pressed his case directly with the president — arguing that the Paris accord was a product of globalism and unpopular with Trump’s base — and also worked with Pruitt to tilt the talks in that direction, providing political ballast to the policy and legal arguments made by others on his side.

Ivanka Trump, meanwhile, helped lead the effort to stay in the deal. In meetings, she argued that withdrawing could hurt the United States’ global image and weaken its moral authority abroad. She and her allies pushed the case that the president would have more leverage if he remained part of the agreement and negotiated from within.

The opposing camp, however, dismissed the substance of her appeal, brushing off her concerns as a hand-wringing question: “What will the world think of us?”

She also understood she might not be successful in swaying her father. But she helped implement a process in which Trump heard voices from all perspectives, from both inside and outside the administration.

Jared Kushner, a senior White House adviser and Ivanka’s husband, agreed with the president that the Paris agreement was a bad deal. He felt that the carbon emissions standards were too high and that a U.N. fund that helps developing countries counter climate change was costing the United States too much. But he, too, felt Trump should not withdraw but simply renegotiate better terms.

Another, smaller contingent tried for an outside-the-box fix: Marc Short, Trump’s director of legislative affairs, argued that the climate pact could be considered a treaty, in which case the president should send it to the Senate, which would need to ratify it by a two-thirds majority. Chief of Staff Reince Priebus and Nick Ayers, a senior strategist for Vice President Pence, both supported the idea. But it never gained much traction because the agreement was specifically crafted as an agreement that did not need Senate ratification.

Some of the efforts to dissuade Trump from withdrawing actually had the reverse effect, further entrenching his original position. When Trump heard advocates arguing that the era of coal was coming to an end — something Cohn told reporters on last week’s foreign trip and also a frequent talking point by some cable news pundits — Trump only became more adamant that pulling out of the Paris pact could help rescue the U.S. coal industry, said a Republican operative in close contact with the White House.

“When he hears people make comments like ‘Coal jobs don’t matter anymore’ or ‘Those are going away,’ he thinks of all those people who got the election wrong and didn’t realize that, no, these people are important to us,” the operative said. “That’s when his populist message kicks in. It pushes him.”

Pressure from leaders abroad also backfired. One senior White House official characterized disappointing European allies as “a secondary benefit” of Trump’s decision to withdraw.

When Trump touched down at a humid Sicilian air base last week, European leaders were already girding up for an argument at the G-7 summit. In Brussels, the president had just castigated NATO allies for their defense spending. But as leaders spoke during a closed-door NATO dinner, not one directly confronted him, seeking to save their political capital for a contentious discussion about climate change in Italy.

In the end, several officials said, the Group of Seven summit felt more like a Group of Six against One, at least on climate issues, as every other leader went around the table urging Trump to remain in the Paris accord.

“There is a situation where six — if you take the E.U., seven — stand against one,” Merkel said after the meeting.

Merkel, who might be the ­second-most powerful leader in the world after Trump, also pressed a moral-based argument, according to one official who was in the room. If the United States pulled out, what would be the message to countries in Africa that could suffer most from global warming and nations like Fiji that are drowning under rising sea levels?

The official added that another leader brought up political arguments: Does the United States want to preserve the U.S. lead on the topic or hand it off to China and India? And a third made an economic pitch: By encouraging renewable energy, you boost the economy, you boost innovation and you stay competitive.

But Trump seemed unmoved by any of the appeals, instead telling the group that this was what he had promised during his election campaign and that he was protecting his voters, according to the official.

On the plane back from Sicily, Merkel did little to hide her disappointment, according to someone who traveled with her. She raved about Macron and his “keen perception.” There was no such praise for Trump, of whom she could only say, “He listened for hours.”

The Europeans were hardly the only ones upset by the president’s decision. Among administration aides who wanted Trump to stay in the agreement, there was growing frustration, bordering on despondency, that they had been unsuccessful in their effort.

Many had given up high-paying jobs outside the administration, sacrificed their quality of life, and were facing daily leaks and palace intrigue stories — only to feel as if they had been unable to influence the president on an issue of top importance.

Silicon Valley executives and other CEOs were also upset. Lloyd Blankfein, the chief executive of Goldman Sachs, where he led the firm along with Cohn, took to Twitter for the first time ever Thursday to criticize the Paris withdrawal, writing, “Today's decision is a setback for the environment and for the U.S.’s leadership position in the world.”

Musk, the CEO of Tesla, who had worked closely with Kushner on several of his key initiatives, also used Twitter to announce his departure from White House advisory panels: “Am departing presidential councils. Climate change is real. Leaving Paris is not good for America or the world.”

A longtime Republican operative who is in touch with the administration said Trump’s decision could jeopardize Kushner’s reputation and outreach on unrelated topics. “If it looks like Jared has gone wobbly on his commitment to climate and is succumbing to some of the baser instincts, that would be a serious problem for his relationship with American CEOs and these Silicon Valley titans,” said the operative, speaking on the condition on anonymity to share a candid opinion.

But the president’s mind was largely made up: He would withdraw from the Paris accord.

If he needed a nudge, though, one came from France over the weekend. Macron was quoted in a French journal talking about his white-knuckled handshake with Trump at their first meeting in Brussels, where the newly elected French president gripped Trump’s hand tightly and would not let go for six long seconds in a show of alpha-male fortitude.

“My handshake was not innocent,” Macron said. He likened Trump to a pair of authoritarian strongmen — Russian President Vladimir Putin and Turkish President Recep Tayyip Erdogan — and said that he was purposefully forceful because he believed his encounter with Trump was “a moment of truth.”

Hearing smack-talk from the Frenchman 31 years his junior irritated and bewildered Trump, aides said.

A few days later, Trump got his revenge. He proclaimed from the Rose Garden, “I was elected to represent the citizens of Pittsburgh, not Paris.”

Birnbaum reported from Brussels. Robert Costa and Damian Paletta in Washington and Stephanie Kirchner in Berlin contributed to this report.