Tesla Motors said on Wednesday that it planned to invest about $2 billion in a large-scale factory to produce cheaper batteries for a mass-market electric car within three years.

The company, which makes all-electric luxury sedans, indicated that it would build the factory in the American Southwest, without specifying where. Nor would it name its partners, who it said would invest up to another $3 billion in the factory through 2020.

Tesla said the factory would allow it to develop and cut the costs of its batteries for its vehicles more quickly, in part by producing finished batteries from metal ore instead of from components. Sales of its Model S sedan, which costs $70,000 and higher, have been constrained by a battery shortage, the company has said.

Analysts said that Tesla needs more batteries if it is to make its third-generation vehicle, an electric sedan that will be sold for less than $40,000. Panasonic currently makes batteries for the Model S.