Elon Musk is breaking his ties with the White House now that President Donald Trump has said he will pull the US out of the Paris Agreement on climate change.

The Tesla and SpaceX CEO said on Wednesday that he would have "no choice" but to leave the two advisory councils he sits on if the US withdrew from the landmark climate deal — a commitment he reiterated on Thursday after Trump made the announcement.

"Am departing presidential councils," Musk tweeted. "Climate change is real. Leaving Paris is not good for America or the world."

Musk is on two of Trump's councils: an economic advisory board and the Manufacturing Jobs Initiative.

Musk has reportedly used his access to the president to push for a carbon tax, but ties to the White House could have been beneficial to Musk's massive infrastructure project: a tunnel under Los Angeles. Musk has attended three meetings at the White House about US manufacturing and infrastructure spending.

Musk chose to remain on the two councils in the wake of criticism of the president's executive order on immigration earlier this year, but he's drawing the line at withdrawing from the Paris Agreement.

The Paris Agreement lays out a framework for countries to phase out fossil fuels and adopt clean energy in an attempt to prevent the planet from warming more than 1.5 degrees Celsius (2.7 degrees Fahrenheit) above preindustrial levels. It's the cornerstone of President Barack Obama's climate legacy.

Musk on Wednesday said he had used his position on the councils to advise Trump to remain committed to the Paris Agreement.

Several executives are opting to remain on the White House advisory councils after Trump's announcement.

Ginni Rometty, the CEO of IBM, will stay on Trump's business advisory council, a representative told Washington Post reporter Brian Fung, as will Mary Barra, the CEO of General Motors, Reuters' David Shepardson reported.