Twenty miles east of Sparks, Nevada, a factory is rising from the red dirt of the high desert. It doesn't look like much—a few completed structures amid exposed steel girders—but this building, dubbed the Gigafactory, is the key to Elon Musk's sweeping plan to remake transportation.

The Gigafactory is where Tesla Motors will build the batteries that power its electric vehicles. The company has long imported batteries from Asia, but if it is to meet its CEO's goal of producing 500,000 cars a year, it must build those batteries here. There's simply no other way to meet its own demand, because the company expects to use more batteries in 2020 than were produced worldwide in 2013.

"The factory is the machine that builds the machine," Musk says, sitting in the lobby of his new building.

When finished, the Gigafactory will cover 5.8 million square feet. Musk, never given to understatement, promises it will be beautiful. Plans call for a jewel-shaped building topped by a roof glittering with solar panels.

Tesla

Crews broke ground in June, 2014, and Musk says EV batteries will start coming off the assembly line next year. That seems optimistic, given that just 14 percent of the factory is finished, but 1,000 people are working seven days a week to hit that deadline.

Those crews work among the Tesla employees already building Powerall and Powerpack home and industrial energy storage units using cells built at Tesla's factory in Fremont, California. (The company plans to start producing cells, which are combined to form the big packs in cars, at the Gigafactory.)

Robots will do much of the work in a factory with shiny grey floors and white walls with red trim. Huge red X-shaped braces secure the walls, providing a measure of seismic security. Engineers work at desks not far from the production line, so they can keep a close eye on the machine that will make the machine. A sign taped up in the break room reads "Reno Supercharger," a reference to the company's EV quick-charge stations.

The factory will be heavily automated, but machines can't do everything, so the factory also will employ some 6,500 people when it hits full production.

Tesla

Finishing the factory is imperative. Tesla plans to start building the Model 3 sedan in 2018, and wants to produce half a million vehicles annually the same year. The only way that works is if Tesla can dramatically increase battery production while bringing down costs. Global demand for the limited supply of lithium-ion batteries—used in everything from power tools to cell phones to automobiles—will grow as automakers build more hybrids and EVs.

“You just look at the math. If you’re going to be 50-plus percent of a market, you’re in a really bad position unless you control that supply chain," says Brook Porter, a senior partner at Kleiner Perkins. "He had to take control of it.”

Gigafactory, a joint venture with Panasonic and other partners, brings everything needed to build batteries under one enormous roof.__ __Raw materials like lithium will eventually arrive by rail. Tesla won't be getting the stuff directly from a mine, but the supply chain doesn't start far from there. "It will be a fairly basic level of incoming material that gets built up," Musk says.

The assembly lines will do everything from make the individual cells—cylinders a bit bigger than an AA battery—to assembling the immense packs that power a Model S or store energy in someone's garage. Tesla doesn't disclose its costs, but says doing it all in-house will drive down the cost of a battery by 30 percent.

Controlling all aspects of manufacturing also lets Tesla embrace new battery chemistries and technologies sooner. It won't have to wait for a supplier to develop the cells; it can simply start producing them. That will be essential as the company implements Musk's Master Plan Part Deux (he really called it that), which outlines his plan to create a vertically integrated company that builds electric vehicles, batteries to store the power to propel them, and the solar panels to generate that power. He also wants to electrify everything from pickups to busses to 18-wheelers.

This being Musk, the big ambitions don't end with the factory's grand opening on July 29. Musk says it's entirely possible Tesla could build Gigafactories everywhere it needs batteries, including Europe, China, and India. Here in Nevada, the company bought another 1,864 acres next door. That's enough room to double the Gigafactory's size. Just in case.