GRÜNHEIDE, Germany — The visitors from Palo Alto, Calif., were shown how Berlin, a hive of tech start-ups that likens itself to Silicon Valley, is just a short commute away.
They were promised building permits in four weeks rather than the customary 11 months.
And they were taken aloft in a 44-year-old Russian biplane for a leisurely tour of the site.
And it worked. Elon Musk, the chief executive of Tesla, decided to build the carmaker’s first major European factory in Grünheide, a village just outside Berlin and surrounded by undeveloped tracts.
Mr. Musk made the announcement during seemingly impromptu remarks at an automotive awards ceremony in Berlin last week.
But the decision was months in the making, involving an elaborate courtship by local officials eager to attract not only the jobs that Tesla would bring — an estimated 2,000 to 3,000 within two years and eventually as many as 7,000 — but also the prestige. Somehow, the officials managed to keep the negotiations secret until Mr. Musk sprang the news.
A lot of things could still go wrong. Tesla, which has opposed unionization at its plant in Fremont, Calif., may chafe at German labor laws that give workers a say in management and limit overtime. Environmental groups may object to manufacturing on land near a nature preserve. The notoriously unpredictable Mr. Musk could change his mind.
Still, the decision was hugely significant for Germany, where cars are the biggest export and the backbone of the economy.
The news has temporarily quieted rising alarm that the German auto industry faces serious disruption from a transition to battery-powered cars like those made by Tesla.
A recent government study concluded that the switch to electric vehicles could cost Germany 114,000 jobs by 2035 and shave 0.6 percent from its gross domestic product. That is because electric cars have fewer moving parts and are simpler to make.
In addition, battery cells are made almost exclusively outside Germany and must be imported. German suppliers of parts for internal combustion engines, like pistons, ignition systems or emissions control equipment, face declines in sales.
Tesla’s assembly plant would offset some of the job losses, and the company also plans to build batteries in Germany.
Based in Palo Alto, Tesla has already been taking market share from the German manufacturers BMW, Volkswagen and Daimler, the maker of Mercedes-Benz cars. The Tesla Model 3 has become best-selling battery-powered car in Europe, a segment that is small but growing fast.
With Tesla near Berlin, the established German carmakers “will have a better view of what Tesla is doing,” said Felipe Munoz, a senior analyst at the market research firm JATO Dynamics. “They will need to accelerate their electrification plans.”
Tesla did not respond this week to requests for comment, but Mr. Musk indicated that one attraction of Germany was its automaking tradition and deep pool of engineering expertise. That could be a reason he did not choose a country like Poland or the Czech Republic, where labor costs are much lower.
Tesla is ahead of the German carmakers in designing electric cars that people want to buy, but Daimler, BMW and Volkswagen can teach it a lot about how to churn out cars by the millions. While Tesla has had well-documented problems scaling up its manufacturing, Volkswagen has just begun mass producing an electric hatchback in Zwickau that will undercut the Model 3 on price.
“Some of the best cars in the world are made in Germany,” Mr. Musk said while appearing at an industry event in Berlin last week alongside Herbert Diess, the chief executive of Volkswagen. “Everyone knows that German engineering is outstanding, for sure.”
The state of Brandenburg, which includes Grünheide and was once part of East Germany, was a long shot to win the Tesla plant. The center of gravity of the German auto industry is in the southern states of Bavaria, home of BMW, and Baden-Württemberg, home of Daimler. Brandenburg, on the other hand, is known by some as the home of Berlin’s new airport, whose construction has been plagued by technical problems and cost overruns and is seven years behind schedule.
The local effort to persuade Tesla officials was led by Jörg Steinbach, the economics minister of Brandenburg and a member of the left-leaning Social Democratic Party. He set out to prove that the sometimes ponderous state bureaucracy could move at Silicon Valley speed, and he was the one who promised the expedited permits.
Mr. Steinbach also chartered the Antonov biplane to sell executives on the virtues of the proposed factory site. (The plane seats up to 12 people, and Antonovs are maneuverable enough to be used as crop dusters.) It helped that the site had already been approved for a factory that BMW decided to build in Leipzig instead.
Arne Christiani, the mayor of Grünheide, said officials had strained to be helpful because they hoped the factory would lure back working-age people who had left for the cities. He joked that Teslas could be rolling off the assembly line sooner than planes begin taking off from Berlin’s much-delayed new airport.
“We’ve been making bets on what happens first,” he said.
There was a tense moment when, during a conference call between German officials and Tesla executives, it emerged that Mr. Musk was under the impression that the site was in Berlin proper.
“I told him, ‘Well, not quite,’” Mr. Steinbach recalled. “‘It’s actually in Brandenburg.’”
Since the fall of the Berlin Wall 30 years ago, Berlin has spawned a thriving arts and start-up scene. It was obviously important to Mr. Musk to be there, Mr. Steinbach said, noting that the plant would be called Gigafactory Berlin in the Greater Berlin Region.
On Nov. 12, Mr. Musk met with the team from Brandenburg in the Hotel Adlon, which once stood in the shadow of the Berlin Wall and is freighted with history. Tesla and the local officials signed a one-and-a-half page letter of intent. Hours later, Mr. Musk delivered the news while receiving a Golden Steering Wheel award from the Bild newspaper.
“I actually have an announcement, which I think will be hopefully well received,” Mr. Musk said from the stage. “We’ve decided to put the Tesla Gigafactory Europe in the Berlin area.” The audience gasped and applauded.
Questions remain, particularly about how Tesla’s high-intensity, 24/7 work ethic will adapt to Germany, where factory managers are expected to consult with employee representatives before making major decisions.
“The labor laws are distinctly different here,” said Olivier Höbel, head of the IG Metall union in Berlin, Brandenburg and Saxony, which represents autoworkers.
But he added, “We are very happy about the decision.” The union will work with Tesla, he said, “to create the perfect climate that the project becomes a full success.”
Christopher F. Schuetze reported from Grünheide, and Jack Ewing from Frankfurt.