Tesla is the top maker of all-electric autos, and it completed its merger with SolarCity, a leading manufacturer of solar energy panels, days after the presidential election.
Elon Musk, the visionary founder of both companies, openly criticized Mr. Trump's candidacy, saying on CNBC just before the vote that he was "not the right guy" for the job.
More from NYT:
Mr. Musk has pressed for a carbon tax to combat global warming, which Mr. Trump once dismissed as a Chinese hoax. The mere mention of a carbon tax inflames the old guard of the energy industry.
Moreover, both Tesla and SolarCity benefit from federal subsidies. Robert E. Murray, a coal executive and Trump supporter, has called Mr. Musk "a fraud" for accepting $2 billion in government handouts.
So why have Tesla shares surged since Mr. Trump's election, closing this week within striking distance of a record high?
Adam Jonas, a prominent automotive analyst at Morgan Stanley, upgraded Tesla stock to overweight last week, with a target price of $305 a share. (It was trading this week at about $255.)
"When you look at the businesses Tesla is in, you see many areas of overlapping interest" with the Trump administration, Mr. Jonas told me. "To the extent the new administration prioritizes the creation of valuable, innovative high tech and manufacturing jobs, Tesla stands at the epicenter of that."
Shares in pure solar energy companies haven't fared as well, but even they have now regained nearly all the ground they lost immediately after Mr. Trump's victory.
Solar investors "aren't nearly as negative as they were the day after the election," said Andrew Hughes, an alternative energy analyst for Credit Suisse.
One reason for that shift seems to be a budding bromance between Mr. Trump and Mr. Musk. The president-elect invited Mr. Musk to Trump Tower in December as part of a group of technology executives and named him to his strategic and policy forum of business leaders.
And Mr. Musk was with a group of manufacturing executives at a White House meeting this week at which, according to a participant, he broached the subject of a carbon tax. Surprisingly, Mr. Trump didn't reject it out of hand.
Mr. Jonas said that the "strategic relationship between Tesla leadership and the new administration is an important development" in his decision to upgrade Tesla stock.
"That Trump would be relying on Musk as an adviser has come as quite a surprise to many people," Mr. Jonas said.
A major fear of investors in solar power was that a Trump administration would end the federal subsidies so reviled by fossil fuel proponents. While that remains a concern, the most recent jobs data suggests that the subsidies have led to a surge in new well-paid jobs, exactly what the president has advocated.
This month, the Energy Department noted in its annual energy and jobs report that "solar technologies, both photovoltaic and concentrated, employ almost 374,000 workers, or 43 percent of the electric power generation work force." (Coal, by contrast, accounts for about 86,000 workers.)
"The jobs data is a compelling argument in favor of the tax credits," Mr. Hughes said.
He noted that federal solar subsidies were set to expire anyway in a few years, a result of rare bipartisan cooperation in Congress. Mr. Musk has stressed that solar energy is close to reaching a scale where federal subsidies will no longer be needed.
And Tesla is also expanding rapidly. Tesla employs 25,000 workers in the United States and could easily double that as it ramps up production for its new Model 3 and expands its Gigafactory, a lithium ion battery manufacturing operation in Nevada. "I don't know what kind of multiplier you put on that, but it's a significant boost to the economy," Mr. Jonas said.
Federal subsidies for electric vehicles will also end once a manufacturer hits 200,000 vehicles, a level Tesla may soon reach.
Mr. Trump and Mr. Musk appear to have other areas of overlapping interest as well. Mr. Musk has broached the subject of the nation's aging electricity transmission grid in conversations with Mr. Trump, according to an insider with knowledge of the discussions.
Mr. Musk has advocated a so-called smart grid and has said that eventually Tesla will offer grid services, such as batteries that can be added to the grid and paired with solar and wind farms. This is the kind of high-impact infrastructure project that Mr. Trump has supported.
And Tesla's success could help fend off Chinese efforts to compete or even dominate in what could be an important piece of the car industry's future.
But the ultimate bond between the two may simply be that they both like to think big.
As Joel Achenbach has reported in The Washington Post, Mr. Musk seems to have captured the new president's imagination with his SpaceX project — which designs, manufactures and launches advanced rockets and spacecraft — and his fascination with transporting human life to other planets. A manned mission to Mars (a joint venture between NASA and SpaceX that would reduce the costs and risks to taxpayers) might well become Mr. Trump's version of "landing a man on the moon and returning him safely to the Earth" within a decade, the challenge that President John F. Kennedy set before Congress in 1961.
It's still early in the Trump administration, and some (or all) of this may turn out to be wishful thinking by fans of Mr. Musk, Tesla investors, environmentalists and hopeful space colonists.
"I want to believe that Trump won't kill solar," Mr. Hughes said. "But there's still a lot of uncertainty. The big question: Will he take away the tax credits?"
Still, there's a growing sense that Mr. Trump and Tesla can not only coexist, but even thrive together. "You don't have to be anti-electric to be pro-fossil fuel," Mr. Jonas said.