Business leaders across the United States have been navigating a new world of trade-offs since Donald Trump became president last month. But perhaps no major chief executive has wrestled as directly or frequently with his or her connections to Trump as Elon Musk, the founder of Tesla and SpaceX.

While Silicon Valley has generally approached Trump with caution, Musk joined a business council advising the White House. As an inventor who is trying to build up manufacturing in the United States, he had a natural affinity with Trump. On Wednesday, he had a private phone conversation with Vice President Mike Pence.

But the recent executive order that temporarily halted immigration from seven Muslim-majority countries has exposed the business executive to criticism. Like other executives, Musk has been forced into the difficult position of defending the merits of engaging with the White House while not alienating key customers or employees.

Tech investor Fred Wilson told the business news site Quartz, “For the CEOs that have chosen to get involved with Trump in an advisory way: When you lie down with the dog, you’re going to come up with fleas.”

In response to a story about Musk meeting with Trump, eBay founder Pierre Omidyar tweeted Saturday that sitting down with opponents is effective only “if it’s in good faith. Trump camp uses you for legitimacy.”

On Twitter, users were pointed in their criticism: “It is becoming clearer that it is time for you to stop working with Trump. How many Tesla sales have you lost as of now?”

Musk has maintained on social media that his role as an adviser should not suggest he supports all of Trump’s policies. Instead, he says, his presence offers an opportunity to challenge the White House on issues such as immigration and climate change and raise more moderate points of view that might otherwise be left out of the conversation.

“People should push to have as many moderates advising the President as possible. Blind hate is never the right answer,” Musk tweeted Sunday after a Twitter user said his friends were “disavowing” Musk because of his Trump connection.

Tesla declined to make Musk available for an interview.

After the executive order was signed, executives from Google, Facebook, Twitter and other major tech firms expressed their dismay through internal memos and social-media posts. Then, last weekend, many big-name tech firms took the rare step of filing a joint legal brief calling the order “unlawful.”

Tesla and SpaceX signed on to the brief a day after it was filed.

A federal appeals court Thursday continued a freeze on the executive order, allowing refugees and immigrants who were previously banned to enter the United States.

The angry response to the executive order prompted another Silicon Valley executive, Travis Kalanick of Uber, to resign from Trump’s advisory council. But Kalanick and Musk run very different companies.

While Uber has built its business on positive public opinion and thumbing its nose at regulators, Tesla and SpaceX operate in heavily regulated industries and rely on the government for financial incentives.

“Advisory councils simply provide advice and attending does not mean that I agree with actions by the Administration,” Musk wrote Feb. 2. “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.”

In his advisory role, Musk has access to Trump and his top administrators. It’s possible this relationship could end up enriching Musk and his shareholders.

Last month, a Morgan Stanley analyst suggested that investors should buy Tesla stock, in part because of his access to the new administration. Musk’s vision of putting humans on other planets, especially Mars, and redefining ground transportation through cars that are autonomous and free of fossil fuels will depend on the government’s support.

Adam Jonas, the analyst, said that while there might be some customers who disagree with Musk, “We would be surprised if that would represent a significant impediment to his business . . . what he’s explained to investors over the years is there is a bigger mission going on.”

Realistically, most chief executives cannot afford to rebuff the White House even if they disagree with Trump’s policies, said John Mayo, executive director at Georgetown University’s Center for Business and Public Policy.

Ultimately, the upheaval in governance and policymaking that his administration has ushered in creates a tremendous business opportunity that executives would be remiss to pass up, Mayo said.

“There is simply nothing to be gained from sitting on the sidelines,” Mayo said. “That leaves the fate of your business and industry to others to decide.”

Tech investor and former AOL executive Steve Case has served on various advisory committees under former presidents Clinton, Bush and Obama. There is always partisanship to contend with, he said. But ultimately, policymaking benefits from having more voices, not fewer, he said, particularly when opinions on an issue are so divided.

“I understand why some people think the right way is to protest, and that’s a healthy part of our democracy,” Case said. “But business leaders need to be at the table, particularly people who bring that tech and entrepreneurial perspective to the table.”

Read more from The Washington Post’s Innovations section.