Photo: Photo illustration by The Wall Street Journal; David Paul Morris/Bloomberg News

During a tour this spring at Tesla Inc.’s electric-car factory in Fremont, Calif., Elon Musk asked why the assembly line had stopped. Managers said automatic safety sensors halted the line whenever people got in the way.

Mr. Musk became angry, according to people familiar with what happened. His high-profile gamble on mass-producing electric cars had lagged behind since production began, and here was one more frustration. The billionaire entrepreneur began head-butting the front end of a car on the assembly line.

“I don’t see how this could hurt me,” he said of vehicles on the slow-speed line. “I want the cars to just keep moving.”

When a senior engineering manager involved with the system explained that it was a safety measure, Mr. Musk told him, “Get out!” Tesla said the manager was fired for other reasons.

One of the world’s most celebrated and controversial entrepreneurs, Mr. Musk operates as though he is the only one who can deliver on his boundless ambitions, in electric cars and solar power, as well as his grand missions to ferry people to Mars and fix Los Angeles traffic, said people who have worked for him.

He craves perfection and can frustrate underlings by taking matters into his own hands, those people said. He asks a lot of questions but answers to no one, according to friends, associates and relatives. Dozens of senior executives have churned through Tesla, leaving him isolated.

Judged even by the egomaniacal standards of Silicon Valley, this means that bets on Elon Musk’s companies are, in fact, bets on Elon Musk.

So far, they have paid off. Tesla’s market value—$50 billion-plus, even after a recent stock price drop—rivals those of traditional U.S. car makers. His rocket company, Space Exploration Technologies Inc., or SpaceX, is valued at more than $20 billion.

To many investors and analysts, Mr. Musk’s tweet on Aug. 7—“Am considering taking Tesla private at $420. Funding secured”—and his decision 16 days later to scrap the plan, represent the other side of the coin: single-mindedness that can look like recklessness and even raise questions about Mr. Musk’s fitness as chief executive.

Federal securities regulators have started a formal investigation into whether Mr. Musk’s tweet violated the law by misleading investors. Friends and family are concerned that Mr. Musk is fatigued and overworked.

Mr. Musk said his actions and rapid decision-making can be misunderstood as erratic behavior. “It is better to make many decisions per unit time with a slightly higher error rate, than few with a slightly lower error rate,” he said last weekend in a series of emails with The Wall Street Journal, “because obviously one of your future right decisions can be to reverse an earlier wrong one, provided the earlier one was not catastrophic, which they rarely are.”

Tesla said Mr. Musk, in a safety hat, had tapped, not headbutted, the car on the assembly line that day, and that the system was adjusted without jeopardizing safety.

Assembly robots on the Model 3 assembly line in June at the Tesla factory in Fremont, Calif. Photo: Brian Molyneaux for The Wall Street Journal

Short sellers have amplified attacks against Tesla and Mr. Musk over the past months, especially as Tesla struggled to meet production goals for its Model 3, the vehicle intended to bring electric cars to the masses. The will-he, won’t-he drama that made headlines in August broadened criticism of Mr. Musk.

“Everyone that believes in the company would prefer the controversy incited by Elon would be toned down, but you can’t have Tesla without Elon Musk to drive it,” said Brett Winton, research director at ARK Invest, a New York-based investment firm that owns about $182 million worth of Tesla stock.

Mr. Musk, supremely confident, invoked the language of Las Vegas gambling to explain his go-private tweet and subsequent about-face.

“If the odds are probably in your favor, you should make as many decisions as possible within the bounds of what is executable,” Mr. Musk said in emails to the Journal. “This is like being the house in Vegas. Probability is the most powerful force in the universe, which is why the house always wins. Be the house.”

The question now is whether Mr. Musk—however brilliant, charismatic and inspiring—can continue to keep the odds in his favor.

Elon Musk in 2011 holds a news conference about renovating the launchpad at Vandenberg Air Force Base in Southern California for use by SpaceX. Photo: Gene Blevins/ZUMA PRESS
High-speed success

Mr. Musk, 47 years old, has a net worth estimated by Forbes at roughly $20 billion, and his allies warn about betting against him.

“He sets goals beyond people’s capacity because his capacity is so much greater than everyone else’s,” said Scott Haldeman, a Southern California neurologist and Mr. Musk’s uncle.

Risk-taking runs in Mr. Musk’s family. His maternal grandfather, Dr. Joshua Haldeman, left Canada for South Africa when his children were young. The grandfather later piloted one of the first flights from South Africa to Australia and searched for the Lost City of the Kalahari, a desert ruin.

As a child growing up in South Africa, Mr. Musk had a voracious appetite for books and the capacity to devour information. “The curiosity he had was a driving force,” his uncle, Dr. Haldeman, recalled—whether about medicine, building a business or commercial farming.

Elon Musk’s brother, Kimbal, during an appearance at the Milken Institute Global Conference in 2016. Photo: Patrick T. Fallon/Bloomberg News

His childhood was also marked by difficulties. His father, an engineer with an interest in an African mining operation, and mother, a model with master’s degrees in dietetics and nutritional science, divorced when he was 8.

Elon’s Orbit

The entrepreneur's grand bets have reaped a fortune worth more than $20 billion

Zip2

CO-founder, CTO

Web publishing software company founded in 1995. Sold in 1999 to Compaq for about $300 million, netting Musk $22 million.

X.com

Co-founder, CEO

Online payments company founded in 1999. Later became PayPal and sold to

eBay for $1.4 billion,

yielding Musk over $100 million.

SpaceX

founder, CTO, CEO

Started in 2002.

Musk owned 54%

of the $21 billion

rocket company

as of late 2016.

Tesla

CEO

The electric car company started in 2003 and is valued at $53 billion. Musk owns about 20%.

SolarCity

Chairman

The solar panel company was co-founded by Musk’s cousins in 2006. He owned 22% in 2016 when it sold

to Tesla for more than

$2 billion.

Neuralink and

Boring Co.

co-founder

Musk founded the tunnel digger and brain computers companies in 2017.

Note:

Tesla valuation

as of Aug. 30.

Sources:

the companies;

Forbes (net worth)

Mr. Musk’s bookishness seemed to make him a target at his all-boys school in Pretoria, Dr. Haldeman said, where classmates distinguished themselves in such sports as rugby and cricket. Mr. Musk’s brother, Kimbal, about two years younger, became his best friend and confidant.

At age 17, Mr. Musk moved to Canada and later enrolled at Queen’s University. He later transferred to the University of Pennsylvania, where he studied physics and economics. He hosted house parties for as many as 500 people, charging $5 to $10 at the door, said Adeo Ressi, a former college roommate.

During the 1990s dot-com boom, the Musk brothers started an internet business called Zip2, which helped newspapers go online. Four years later, in 1999, they sold it to Compaq Computer. At age 27, Mr. Musk walked away with $22 million. He spent $1 million on a McLaren F1 supercar and bet the rest on his next startup, X.com, which became PayPal .

While on vacation in Africa, Mr. Musk contracted a severe case of malaria. The prospect of dying prompted Mr. Musk to reconsider his life, family members said, and he concluded, with some grandiosity, that he could save humanity by colonizing Mars and creating sustainable transportation.

EBay Inc. bought PayPal for $1.4 billion in 2002. As the largest shareholder, Mr. Musk collected more than $100 million. He was 31.

In October 2000, Peter Thiel, left, then the chairman of X.Com Corp., and Elon Musk, at the time the company’s president and CEO. Photo: Paul Sakuma/ASSOCIATED PRESS

Mr. Musk shoveled most of the money into SpaceX, the rocket company he hoped would help one day colonize Mars; Tesla, the auto maker that would make internal-combustion engines obsolete; and SolarCity, to reduce the world’s reliance on grid electricity.

Wealth didn’t seem a singular goal. When Tesla veered near bankruptcy in 2008, Mr. Musk used his money to save the company.

He still believes his work has no less a mission than saving humanity. Mr. Musk splits his time between Southern California, where SpaceX is located, and Tesla in Northern California, sometimes working as many as 100 to 120 hours a week, according to Mr. Musk and people close to him.

He expects much the same of his employees and sets a high-profile example. At Tesla, Mr. Musk works long hours on the factory floor. People who have worked under Mr. Musk say he leads his companies toward the impossible.

Mr. Musk surprised the auto industry with Tesla’s Model S sedan, persuading consumers to buy electric cars because they were sexy. Mr. Musk attracted top engineers who adopted as religion his goal of replacing gas-powered cars.

Elon Musk discusses the features of Tesla’s Roadster, the company’s flagship electric sports car, during a talk in February 2008. Photo: Ryan Anson/Bloomberg News

He also is described as an obsessive taskmaster. Former executives say they had to be prepared to know the smallest details. If there was a problem on the assembly line, they said, it was best to show it to him in person.

When the Model X sport-utility vehicle was having problems with the back seats, Mr. Musk helped engineers design a new bracket, a person familiar with the matter said. He spent years on the door handles for the Model S sedan, another person said. For the Model 3, he became consumed with automation, which he later acknowledged contributed to months of delays.

Some former employees said they preferred communicating with Mr. Musk by email. After pushing send, they said, they would wait nervously, hoping for a two-letter response that said: “OK.”

A lengthy response from Mr. Musk was likely criticism or entirely new marching orders, one former employee said. He also could summon managers to the factory at all hours of the night, former workers recalled.

Senior managers said they found Mr. Musk inspiring and sometimes funny. But when the boss was in a bad mood, they avoided proposing ideas or raising concerns. Some scheduled important meetings after a successful SpaceX rocket launch, when Mr. Musk was buoyant, one of these employees said.

“As long as he kept nodding, I just needed to continue to speak,” a former manager said. “And as soon as he stopped nodding, that’s when you needed to shut up.”

Others said they tried to anticipate his mood by following news of his personal life, even tracking the hair of actress Talulah Riley when she was his second wife, believing Mr. Musk was happiest when her hair color approached platinum.

Elon Musk in June 2010 with then-fiancée Talulah Riley in New York. Photo: Daniel Acker/Bloomberg News
Going it alone

At SpaceX, Mr. Musk has relied on Gwynne Shotwell, company president, to run day-to-day operations. The rocket business is more predictable than Tesla: It has far fewer customers, gets paid before a launch and is privately held, reducing investor pressures.

The executive team at Tesla that Mr. Musk once relied upon for information is depleted. More than 50 vice presidents or higher have left the company in the past two years.

Mr. Musk hasn’t so far found a second-in-command with the expertise or vision that appeals to him, people familiar with his thinking said.

Mr. Musk had long told his executives he didn’t want to be CEO and planned to serve only as long as it took to bring Tesla up to speed, leaving him to focus on product development, people familiar with his comments said. Aides debated who would take his place: Doug Field, the engineering chief, or Jon McNeill, the sales chief.

Both men left Tesla this year, and Mr. Musk assumed their roles instead of hiring replacements. Tesla said neither man was being groomed for CEO.

Mr. Musk said he doesn’t know of anyone better to replace him, in a recent interview with the Journal. “This is not me clinging to be CEO,” he said. He has told aides he worried about the risks to Tesla if he stepped down.

The job takes a toll. Mr. Musk struggles with sleep and has talked about his use of the sleeping drug Ambien. When the drug doesn’t work, according to a person familiar with his usage, fatigue saps his productivity the next day. His five boys—triplets and twins with his first wife, Justine Musk—help relieve his stress when they are all at home in Bel-Air, Calif., this person said.

Elon Musk's market-moving tweet about possibly taking Tesla private is just the latest erratic move in a tumultuous year for the CEO. Photo illustration: Heather Seidel/The Wall Street Journal

When Tesla struggled to ramp up production of the Model X a few years ago, one person recalled Mr. Musk calling an impromptu huddle with workers at the end of the assembly line. The boss gave his thanks, and he choked up when acknowledging the time they sacrificed from their families.

“I’m missing the important days of my family as well,” Mr. Musk said.

Over the years, Mr. Musk’s personal life has taken on a public dimension. In 2012, he indicated in a tweet that he was divorcing Ms. Riley. Tesla’s stock dipped 2% that day, and the company’s communications chief warned him about tweeting news of his personal life, according to former employees.

In a 1999 CNN interview, after selling Zip2 and making his first fortune, Mr. Musk is shown taking delivery of his McLaren F1. “I’d like to be on the cover of Rolling Stone,” he said. “That’d be cool.”

His wish came true in November 2017, and Mr. Musk seems to enjoy his celebrity. “Iron Man” director Jon Favreau and actor Robert Downey Jr. spoke often with Mr. Musk as they developed the movie’s Tony Stark character.

Director J.J. Abrams, whose movies include “Mission: Impossible III” and “Star Wars: The Force Awakens,” said he and Mr. Musk often trade emails and socialize every few months. When Mr. Abrams read this year that Mr. Musk had dug a tunnel near Los Angeles to demonstrate a plan to reduce traffic, Mr. Abrams emailed and said, “I know this sounds bad, but I want to come see your hole.”

The director visited SpaceX’s property and toured a tunnel dug for Mr. Musk’s Boring Co., which seeks to build high-speed, underground transportation. Mr. Abrams designed a logo and asked his production company to put it on a baseball cap.

“Next thing I knew, I saw a photograph of the Boring Company drill with the logo emblazoned on it.” Mr. Abrams said. “I was thrilled.”

Claire Elise Boucher, known as the pop musician Grimes, shared the spotlight with Elon Musk at the 2018 Costume Institute Benefit Gala in May. Photo: Starmax/ZUMA PRESS.

Since at least spring, Mr. Musk has dated Claire Elise Boucher, the pop musician known as Grimes. For her new album, she planned to collaborate with New York-based singer Azealia Banks, according to Ms. Banks’s Instagram feed. Ms. Banks suggested on Instagram after the blockbuster Aug. 7 tweet that Mr. Musk used LSD while tweeting, a claim described by a spokesperson for Mr. Musk as “complete nonsense.” Ms. Banks later apologized on Instagram. Representatives of Ms. Banks and Ms. Boucher declined to comment.

The Tesla board wasn’t happy with Mr. Musk’s use of Twitter , according to a person familiar with the matter, and told him to be more careful. Earlier this summer, he implied in a tweet that a British cave explorer who helped rescue a youth soccer team in a Thailand cave was a pedophile. He later apologized.

Mr. Musk, while freely letting loose his own tweets, finds time to police critics. He looks for the Twitter hashtag $TSLA, populated by short sellers, a person familiar with the matter said. Mr. Musk believes short sellers and critics aren’t just betting against Tesla, they are trying to undermine his “good intentions in the world,” said Mr. Ressi, his college friend.

Mr. Musk told the Journal that in July he emailed Herbert Diess, chief executive of Volkswagen AG , to ask if a Volkswagen employee was criticizing Tesla on Twitter, using a fake name.

The Twitter account ended up belonging to the brother of a Volkswagen worker. “They would definitely be playing with fire, given that they are still paying the fine from their last emissions cheating scandal,” Mr. Musk said. “Diess replied saying it was the guy’s brother. That’s pretty much it.”

Mr. Diess declined to comment. Volkswagen said, “Mr. Diess’s aides handled the details.”

This summer, Mr. Musk also went after Lawrence Fossi, who used the online moniker “Montana Skeptic” to post criticism of Tesla both on Twitter and Seeking Alpha, a crowdsourced content service for financial markets. 

On July 23, Mr. Musk sent a text to the top executive at Mr. Fossi’s company, asking the boss if he knew his employee “was obsessively trashing Tesla via a pseudonym.“

Mr. Fossi, who voluntarily deactivated his Twitter account soon after and stopped writing for Seeking Alpha, said he was surprised Mr. Musk would go to such lengths to squelch criticism: “I’m a nobody and he calls my employer?”

Write to Tim Higgins at Tim.Higgins@WSJ.com, Tripp Mickle at Tripp.Mickle@wsj.com and Rolfe Winkler at rolfe.winkler@wsj.com