Tesla CEO Elon Musk said on Saturday that there was "no way" he could have stayed on the White House advisory councils after President Donald Trump announced in June he would pull the US out of the landmark Paris climate agreement.

Musk's comments came as he was speaking to US governors this weekend. When he was asked about the time he spent on Trump's economic advisory council and the Manufacturing Jobs Initiative, Musk told Axios, "I got a lot of flack from multiple fronts for even trying. Some guy rented billboards attacking me and full-page ads in the NY Times and what not ... just for being on the panel."

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

On Saturday, Musk said he had pushed for environmental sustainability and tried to touch on other issues like immigration, advocating that immigration laws should not be "unkind or unreasonable."

He added that "it was worth" trying to work with President Donald Trump on some issues. "I did my best, and I think in a few cases I did make some progress."

But he said staying on at the White House after Trump pulled out of the climate deal would have meant he didn't see it as a significant step backwards.

"If I stayed on the councils it would be saying that wasn't important, but I think it's super important," Musk said. "The country needs to keep its word. There's just no way I could stay on after that."