It's Tesla Motors' biggest bet yet: a massive, $5 billion factory in the Nevada desert that could nearly double the world's production of lithium-ion batteries.

Tesla officially opened its Gigafactory on Tuesday, a little more than two years after construction began. The factory is about 14 percent complete, but when it's finished, it will be about 10 million square feet, or about the size of 262 NFL football fields. That will make it one of the largest buildings in the world.

An overall view of the new Tesla Gigafactory is seen during a media tour Tuesday, July 26, 2016, in Sparks, Nev. It i??s Tesla Motors'?? biggest bet yet: A massive, $5 billion factory in the Nevada desert that could almost double the world???s production of lithium-ion batteries by 2018. (AP Photo/Rich Pedroncelli) Rich Pedroncelli / AP

The factory is key to the future of Palo Alto, California-based Tesla. The 13-year-old electric car company, which has never made a full-year profit, wants to transition from a niche maker of luxury vehicles to a full-line maker of affordable cars, pickups and even semi-trucks. It also runs Tesla Powerwall, a solar energy storage business for homes and businesses.

The company says making its own lithium-ion batteries at the scale the Gigafactory will allow will reduce its battery costs by more than a third by 2018. Tesla CEO Elon Musk said the factory could easily employ 10,000 people in the next three to four years.

Most immediately, Tesla needs the batteries for its fourth car, the Model 3 sedan, which is scheduled to go on sale at the end of next year. At a starting price of around $35,000, the Model 3 will be Tesla's least expensive vehicle, partly because of battery cost reductions. The batteries for Tesla's current vehicles, the Model S sedan and Model X SUV, are made in Japan.

Tesla unveiled the Model 3 at the end of March. Within a week, more than 325,000 people had put down a $1,000 deposit to reserve the car. After seeing that level of demand, Tesla moved its production plans forward. The company now says it will make 500,000 vehicles per year by 2018, two years earlier than scheduled.

Read More: Apparent Conflicts of Interest May Dog Tesla-SolarCity Deal

To meet that goal, Gigafactory construction is proceeding at a furious pace. Inside the factory, Tesla's partner, Panasonic Corp. — which has invested $1.6 billion into the factory — is installing machines in sealed, humidity-controlled rooms that will start making battery cells before the end of this year.

Byers Market Newsletter Get breaking news and insider analysis on the rapidly changing world of media and technology right to your inbox. This site is protected by recaptcha

Panasonic is also shipping cells from Japan to the Powerwall business, which is operating in another section of the factory. Robots are used to place battery packs into home and office units, which store energy from solar panels and allow users to tap it during peak periods. Musk said the Powerwall business will initially make up about one-third of the Gigafactory's output, but eventually could expand to around half.

Outside, nearly 1,000 workers are laying the groundwork for the factory's expansion, digging trenches and erecting steel supports in the hot, dusty valley. By the second quarter of 2017, 31 percent of the factory will be completed. Eventually, the roof will be covered in solar panels.

Musk noted that some of the area's 10,000 wild horses often drink from the ponds at the construction site. Nevada won the factory thanks in part to $1.3 billion in tax incentives, which will benefit Tesla over a 20-year period.

"I find this to be quite romantic. It feels like the wild West."

"I find this to be quite romantic," he said. "It feels like the wild West."

The factory's name stems from "giga," a unit of measurement that represents billions. One gigawatt hour is the equivalent of generating one billion watts for one hour — one million times that of one kilowatt hour.

Tesla says the factory will be producing 35 gigawatt hours of batteries by 2018. That's the equivalent to the entire world's production in 2014. Tesla CEO Elon Musk has said the factory has the capacity to produce 150 gigawatt hours if it needs to. To put that in context, New York City uses around 52 gigawatt hours of energy per year.

Analysts say bringing battery production in-house, instead of buying batteries like General Motors Co. and other major automakers do, can help bring down costs, but also leaves Tesla exposed. If the Model 3 is delayed, for example, or customers' deposits don't turn into actual sales, Tesla will have extra batteries on its hands and no way to recoup its costs.

"They could be left with a lot of excess capacity in the near term," said Sam Abuelsamid, an analyst with Navigant Research. Abuelsamid says there's also the possibility that advances in battery technology in the longer term could force Tesla to make expensive new investments.

Read More: Tesla Stock Takes a Dip After 'Master Plan'

There are also competitors who could derail Tesla's dreams. Chinese automaker BYD Co., which is backed by Warren Buffett's Berkshire Hathaway Corp., also makes batteries and energy storage systems and is already building battery-powered buses in the U.S. The company hopes to bring low-cost electric cars to the U.S. in a few years.

Musk says there are still plenty of ways for Tesla to reduce costs, including making its factories more efficient and eventually building more battery factories in Europe, China and other regions where its cars are sold.

The company also is using a different type of battery cell in the Model 3 than it did in the Model S and Model X in an effort to reduce costs.