Now playing: Watch this: Trump exits Paris climate agreement

Silicon Valley's tech giants tried to stop President Donald Trump from pulling the US out of the Paris climate accord.

It didn't work.

On Thursday, Trump said the US was dropping out of the agreement to curb global warming despite pleas to remain from Apple, Facebook and Google, as well as Elon Musk, founder of Tesla and SpaceX. Musk also threatened to leave several of the president's advisory councils, a pledge he made good on.

The US joined the Paris agreement in 2015. Nearly 200 countries are part of the accord and have agreed to fight global warming by reducing carbon emissions. Scientists anticipate climate change could push the Earth to dangerous temperatures much sooner if the US retreats from the pledge because the country burns so much energy.

Trump, however, sees the agreement as unfair to the US, and says it will cost the country jobs.

"In order to fulfill my solemn duty to protect America and its citizens, the United States will withdraw from the Paris climate accord, but begin negotiations to re-enter either the Paris accord or an entirely new transaction on terms that are fair to the United States," Trump said from the White House's Rose Garden on Thursday.

The decision came despite a full-court press by tech giants, which urged Trump to keep the US in the pact. The group included Musk, a Silicon Valley magnate who is in the president's inner circle and had argued he could use his position on economic advisory councils to influence the president.

On Wednesday, Musk said he did "all I can to advise" the president and threatened to leave Trump's advisory councils if the US left the agreement. After the announcement, Musk did just that.

Am departing presidential councils. Climate change is real. Leaving Paris is not good for America or the world. — Elon Musk (@elonmusk) June 1, 2017

Disney CEO Bob Iger, another member of the council, tweeted that he had also stepped down.

As a matter of principle, I've resigned from the President's Council over the #ParisAgreement withdrawal. — Robert Iger (@RobertIger) June 1, 2017

Other Silicon Valley CEOs also weighed in.

Apple CEO Tim Cook personally called the White House on Tuesday to urge Trump to stay in the agreement, according to a company-wide email he sent Thursday. He added that Apple's commitment to protecting the environment was unchanged.

"Climate change is real and we all share a responsibility to fight it," Cook wrote."I want to reassure you that today's developments will have no impact on Apple's efforts to protect the environment."

The CEOs of Google, Facebook, Microsoft, HP and Intel also asked Trump in a letter to stay in the agreement. They argued that innovating clean technology would create more jobs, while protecting the country from climate change's devastating effects in the future.

"As other countries invest in advanced technologies and move forward with the Paris Agreement, we believe the United States can best exercise global leadership and advance US interests by remaining a full partner in this vital global effort," the letter reads.

You can see their full letter here.

In explaining his decision, Trump argued the Paris Accord hurts the US economy, kills jobs and burdens on taxpayers. He cited the coal, paper and cement industries as victims of the global pact.

"The Paris Accord is very unfair at the highest level to the United States," Trump said. "I was elected by voters of Pittsburgh, not Paris."

Pittsburgh Mayor Bill Peduto, who has vocally opposed leaving the accord, tweeted that his city will continue to follow the guidelines of the Paris Agreement.

As the Mayor of Pittsburgh, I can assure you that we will follow the guidelines of the Paris Agreement for our people, our economy & future. https://t.co/3znXGTcd8C — bill peduto (@billpeduto) June 1, 2017

The US joined the climate deal under former President Barack Obama, who on Thursday sided with tech leaders, citing the innovation spurred by green technology.

"The Paris Agreement opened the floodgates for businesses, scientists, and engineers to unleash high-tech, low-carbon investment and innovation on an unprecedented scale," Obama said in a statement after Trump's decision.

Amazon released a statement Thursday, saying it would still abide by the Paris climate agreement's rules.

"We believe that robust clean energy and climate policies can support American competitiveness, innovation and job growth," the retail giant said.

Jeff Immelt, the CEO of General Electric, tweeted that he was disappointed with Trump's decision to leave the Paris agreement. "Climate change is real. Industry must now lead and not depend on government," Immelt said.

Salesforce CEO Marc Benioff tweeted that he was "deeply disappointed" with the president's decision and said his company would double its efforts to flight climate change.

Deeply disappointed by President's decision to withdraw from ParisAgreement. We will double our efforts to fight climate change. pic.twitter.com/cmCLf9CoVY — Marc Benioff (@Benioff) June 1, 2017

Al Gore, the former vice president who brought global warming to the forefront of the public debate, criticized the decision on Thursday, calling it "reckless and indefensible."

My statement on Today’s Decision by the Trump Administration to Withdraw from the Paris Agreement: https://t.co/eDEFv5b1nS pic.twitter.com/SzHJU3D0Mr — Al Gore (@algore) June 1, 2017

Microsoft's president and chief legal officer Brad Smith said the company had been actively working to convince the Trump administration not to leave the Paris Agreement. Microsoft had multiple meetings with senior officials in the State Department and the White House over the climate change accord, Smith said.

The tech giant said it will continue to follow the agreement's guidelines for sustainability.

"We are disappointed with today's decision by the White House to withdraw the United States from the landmark, globally supported Paris Agreement on climate change," Smith said.

Google CEO Sundar Pichai also said he was disappointed with Trump's decisions and tweeted that "Google will keep working hard for a cleaner, more prosperous future for all."

Facebook CEO Mark Zuckerberg said in a post a on the social network that withdrawing from the Paris agreement is "bad for the environment, bad for the economy, and it puts our children's future at risk." He added that Facebook has committed that "every new data center we build will be powered by 100% renewable energy."

Uber also weighed in on Trump's decision. "Today's announcement from President Trump that the United States will not honor the agreement is a huge disappointment," wrote Andrew Salzberg, Uber's head of transportation policy and research, in a blog post. "At Uber, we also believe that fighting climate change opens up new opportunities for American innovation and ingenuity to tackle the world's biggest problems."

The withdrawal will take four years to completely exit, and concludes in November 2020, when Trump is up for re-election.

CNET's Shara Tibken contributed to this report.

Multiple updates on June 1: To include statements from former President Obama, Amazon, Elon Musk, Microsoft, Facebook and Uber. Adds Apple email and Iger resignation from council.

Batteries Not Included: The CNET team reminds us why tech is cool.

CNET Magazine: Check out a sample of the stories in CNET's newsstand edition.