Elon Musk and Donald Trump. AP/ Evan Vucci Tesla CEO Elon Musk said he would leave President Donald Trump's advisory councils if the US withdrew from the Paris Agreement.

Trump is planning to pull the US out of the Paris climate deal, the news website Axios reported early Wednesday.

"Don't know which way Paris will go, but I've done all I can to advise directly to POTUS, through others in WH & via councils, that we remain," Musk said on Twitter on Wednesday.

Musk then said he would have "no choice" but to depart Trump's advisory councils if the US pulled out of the climate deal.

Musk sits on two of Trump's councils: an economic advisory board and the Manufacturing Jobs Initiative. Musk has come under fire for his proximity to the Trump administration — some people claimed they canceled their Tesla Model 3 orders because of his involvement in the councils.

Musk has visited the White House three times since Trump took office in January for meetings about infrastructure spending and US manufacturing.

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 above preindustrial levels. It's the centerpiece of President Barack Obama's climate legacy.

Musk has said that a goal of being involved with Trump's advisory councils is to help convert the planet to sustainable energy.

Musk reportedly has used his access to Trump to push for a carbon tax, which would incentivize companies to use energy sources that emit less carbon. In January, Musk endorsed Rex Tillerson for secretary of state because Tillerson, the former CEO of ExxonMobil, has supported such a tax. Musk has for years publicly called for a carbon tax, including at the 2015 United Nations Climate Change Conference in Paris.

"Advisory councils simply provide advice, and attending does not mean that I agree with actions by the administration," Musk said in February. "My goals are to accelerate the world's transition to sustainable energy and to help make humanity a multi-planet civilization, a consequence of which will be the creation of hundreds of thousands of jobs and a more inspiring future for all."