Elon Musk is placing an enormous bet on the world’s largest lithium-ion battery plant—a $5 billion, 10 million-square-foot (930,000 sq m) “gigafactory” that would make enough battery packs to power 500,000 electric cars a year. That is four times the number of electric cars of any brand bought around the world last year, and a whopping 21 times Tesla’s own 2013 sales. In addition to betting on this monumental sales boost, Musk is hoping an inventive rival won’t eclipse his battery technology and render the gigafactory instantly obsolete.

But the deck may be at least partly stacked in Musk’s favor. He appears to be banking not so much on a sharp swing in consumer taste as on a shift already underway in public policy. Over the coming decade, eight US states will begin to require carmakers to sell an estimated 3.3 million low- and zero-emission vehicles. In addition, California will require utilities to buy the capacity to store 1.3 gigawatts of electricity, enough to serve one million homes.

When combined, the required mobile and stationary battery capacity will be so massive that Musk would be scrambling not so much to find buyers as to meet the demand, some say. “Industrywide, you are no longer talking about 500,000 or one million vehicles, but millions of cars that have to be on the road,” Ann Schlenker, director of transportation at Argonne National Laboratory, told Quartz.

Musk says he will ante up $2 billion of the factory’s cost and raise the rest of the money. Here we examine his calculus.

Can you really just order up an electric-car age?

Tesla declined to comment for this story. But the expansion that Musk envisions has solid foundations. The states adopting the so-called “zero-emissions laws” are strung along the US west and east coasts—California and Oregon on one side, and six northeast states on the other. Together, they account for 30% of total US vehicle sales, according to a study last year by Michael Stanton, CEO of the Association of Global Automakers. The states’ forecast of 3.3 million zero-emission vehicles by 2025 is up from about 100,000 today. These vehicles would have to be propelled by batteries or hydrogen fuel cells to comply with the laws.

This scenario has plenty of skeptics. History tells us consumers can be brought along on technological changes that are ordered by regulators, such as the shifts to seatbelts, air bags and smog-control systems. Still, turning to electric cars may be another matter unless sticker prices, which still tend to be far higher than for pure gasoline-driven models, drop sharply, and the distances the cars can drive on a single charge rise substantially.

The US Energy Information Administration, for instance, forecasts that fewer than 500,000 pure electrics will have been sold in the US by 2020—even by the year 2040, the agency says, US motorists will buy just 300,000 pure electrics and plug-in hybrids a year. The wildly diverging sales forecasts are a reflection of the uncertainty surrounding the future of electric vehicles—and why Musk is almost alone in his aggressive approach.

If you could order such a consumer shift by fiat, perhaps China would have managed it. But Beijing’s aim to have 500,000 electric cars on the road by 2015 has fallen far short, with just 50,000 electrics of all types sold overall (paywall) as of last year. As of the first quarter of this year, Tesla had sold just 34,000 cars worldwide since it has been in business.

There’s even more room for doubt about the future of Musk’s gigafactory (paywall), given the fact that no other electric carmaker uses the cylindrical type of battery installed in the Teslas, called the “18650.”

Traditional carmakers have resisted the zero-emissions laws in court, arguing that they might be left holding millions of cars that they cannot sell, and environmentalists fear they will continue to fight the mandates. The rollout of the laws may be delayed by years while infrastructure, costs, and consumer demand catch up with the states’ public-policy hopes.

Finally there are the technological questions. The gigafactory will make commodity 18650s using a standard nickel-cobalt-aluminum lithium-ion (NCA) formulation. But with battery researchers around the world working on a breakthrough, Musk is betting that none will leap ahead of NCA in a way that he cannot simply tweak his machines. He also could be broadsided by hydrogen fuel-cells, which Toyota for one believes are the future.

Is Tesla going to be the winner in the electric-car space?

There is yet another potential challenge to Musk’s gigafactory dreams—even if consumer demand materializes, there is no guarantee that a large percentage of sales will go to Tesla. China’s Wanxiang, for example, says it intends to aggressively market the Fisker brand in the US. The sleek, $103,000 plug-in hybrid Fisker Karma has a fevered fan base similar to the Tesla S (the high-end Model S can cost up to $106,000 with extras.)

Reuters/Lucy Nicholson The challenger.

Over the last two years, Wanxiang has swooped in and bought choice chunks of the embryonic US electric-car market infrastructure, including Fisker, which filed for bankruptcy last year, and A123, a Massachusetts-based lithium-ion battery maker. As part of the Fisker deal, Wanxiang matched one of Musk’s main manufacturing advantages—the acquisition of a cheap car-making factory—when it obtained an abandoned General Motors plant to make its Karmas. (Musk makes his Teslas in Silicon Valley; Wanxiang’s factory is in Wilmington, Delaware.)

Musk needs this to work

Musk appears to be betting three hands here—that the zero-emissions laws, even if late, will remain more or less intact; that consumers will comply with them; and that he can achieve his goal of making a mass-market Tesla by the end of the decade that can sell for $35,000, around half the current base price of the Model S.

The key to the latter is the gigafactory, whose manufacturing economies he says will bring down battery costs by some 30%. That is substantial considering that the battery is the most expensive single component in electric cars. Tesla does not disclose the cost of its batteries, but one estimate is around $15,000 for the 200-mile-range battery in the Model S.

Argonne’s Kevin Gallagher, co-designer of software that calculates the cost of battery manufacturing, told Quartz that Musk’s estimate of 30% savings is reasonable. Musk would chop about $5,000 off the price of the battery, a big step toward the mass-market car.

Tesla has said that it will soon narrow its search for a plant location from five candidates to two, then announce the winner in the summer. The proposed sites are in Arizona, California, Nevada, New Mexico, and Texas.

Musk is already making money from the zero-emissions laws. This year, the laws require that 1% of each car maker’s vehicle sales meet the zero-emissions standard (the percentage ramps up gradually to 15% in 2025.). If a car maker hasn’t done so, it must buy credits from a rival having a surplus.

Currently, Tesla is the go-to shop for emissions credits; since it manufacturers only electric cars, it is swimming in unneeded credits. Last year, each of its S models earned seven zero emissions credits, which sold for $5,000 each, earning Tesla $35,000 in added revenue for each car sold. The price is market-driven, but last year, Tesla earned $131 million from its surplus credits.

Musk has a record of beating skeptics. This time, he appears to believe he is not so much gambling as achieving first-mover advantage. As is plain in the photo above, he seems serenely conscious that almost everyone else—at least for now—is betting against him.