Mr. Musk later added: “We are headed toward either superintelligence or civilization ending.”

At the end of the panel, Mr. Musk was asked how society can best live alongside superintelligence. What we needed, he said, was a direct connection between our brains and our machines. A few months later, he unveiled a start-up, called Neuralink, backed by $100 million that aimed to create that kind of so-called neural interface by merging computers with human brains.

Warnings about the risks of artificial intelligence have been around for years, of course. But few of those Cassandras have the tech cred of Mr. Musk. Few, if any, have spent as much time and money on it. And perhaps none has had as complicated a history with the technology.

Just a few weeks after Mr. Musk talked about his A.I. concerns at the dinner in Mr. Zuckerberg’s house, Mr. Musk phoned Mr. LeCun, asking for the names of top A.I. researchers who could work on his self-driving car project at Tesla. (That autonomous technology was in use at the time of two fatal Tesla car crashes, one in Florida in May 2016 and the other in March of this year.)

During a recent Tesla earnings call, Mr. Musk, who has struggled with questions about his company’s financial losses and concerns about the quality of its vehicles, chastised the news media for not focusing on the deaths that autonomous technology could prevent — a remarkable stance from someone who has repeatedly warned the world that A.I. is a danger to humanity.

The tussle in Palm Springs

There is a saying in Silicon Valley: We overestimate what can be done in three years and underestimate what can be done in 10.

On Jan. 27, 2016, Google’s DeepMind lab unveiled a machine that could beat a professional player at the ancient board game Go. In a match played a few months earlier, the machine, called AlphaGo, had defeated the European champion Fan Hui — five games to none.

Even top A.I. researchers had assumed it would be another decade before a machine could solve the game. Go is complex — there are more possible board positions than atoms in the universe — and the best players win not with sheer calculation, but through intuition. Two weeks before AlphaGo was revealed, Mr. LeCun said the existence of such a machine was unlikely.