Sunrun, the nation’s largest residential solar company, said Monday it is acquiring a leading competitor, Vivint Solar, to form one of the world’s largest providers of solar equipment.

If approved, the all-stock deal would create a company with about 500,000 customers, Sunrun said in a statement. Board members of both companies unanimously approved the deal, it said.

Sunrun said the deal had an enterprise value — that is, including the assumption of debt — of $3.2 billion.

“There’s a mandate to continue to lower costs,” Lynn Jurich, Sunrun’s chief executive and co-founder, said Tuesday during a conference call about the deal. “The businesses are so complimentary. So for us this was the right time to pursue this.”

Sunrun, based in San Francisco, and Vivint, based in Lehi, Utah, have held two of the top three positions in the residential solar market along with Tesla. Sunrun, founded in 2007, overtook Tesla as the nation’s leading residential solar company in 2018. In addition to residential solar panels, Sunrun and Vivint sell residential battery systems.

Shares of both companies were up sharply Tuesday. Sunrun’s stock price was up more than 20%, and Vivint was up about 35%.

Sunrun has focused on financing and installing solar panels and batteries rather than on producing those products itself. “Manufacturing, that’s not our core competency,” Jurich said in an interview with The New York Times in 2018.

The acquisition announcement cited the continuing growth potential for residential solar products, noting that only 3% of U.S. homes were equipped. The combined company would increase Sunrun’s market share to about 15% from about 9% now, according to Ravi Manghani, a research director for Wood Mackenzie.

While the renewable energy industry has weathered the coronavirus pandemic much better than oil and gas businesses, residential solar installations have dropped as many homeowners have cut spending and reduced interactions with other people. Analysts expect Sunrun’s revenue to dip by nearly 5% this year and Vivint’s revenue to increase by less than 5%, according to Bloomberg.

Overall, analysts expect a 25% decline in residential solar installations this year compared to 2019, according to the Solar Energy Industries Association. Most companies have not yet disclosed detailed data for the second quarter when the pandemic forced many people to work from home and businesses furloughed or dismissed millions of workers.

Vikram Aggarwal, founder and chief executive of EnergySage, a solar comparison-shopping market, said that residential installations improved each month in the second quarter and that June sales were higher than in the same month last year. He said Sunrun’s acquisition of Vivint was a significant change for the solar business, especially given the uncertainty arising from the pandemic.

“These are tough times for everybody,” Aggarwal said. “Growth is limited of course because of COVID.”

But he questioned some of the benefits of the acquisition for consumers, given that both companies have relied on direct contact with people for sales and service more than some other companies like Tesla, which has moved to an online sales model. The use of lots of sales and service staff members by both Sunrun and Vivint could raise their costs relative to other installers.

“Publish the options and prices to the consumer online; let the consumers shop on their own time without needing to talk to a sales person,” Aggarwal said. “That has not happened with Vivint and Sunrun yet.”

Jurich countered that both companies do interact with customers online. But she added that because so few homeowners have solar panels or are familiar with how they are installed, it makes business sense to establish more direct relationships with customers.

“There isn’t more penetration because people don’t know about it,” Jurich said. “They still need a lot of education.”

Sunrun and Vivint said the deal would lead to cost savings of up to $90 million a year, which executives argue would benefit their investors and consumers who would be able to buy solar systems for lower prices.

Joseph Osha, an analyst with JMP Securities, said in a research note that “customer acquisition costs have remained stubbornly high” for Sunrun and Vivint. “At first glance, we think the $90 million in cost synergies mentioned in the presentation appears to be a reasonable, and perhaps even conservative, estimate.”