LOS ANGELES — Just four years after its founding in 2006, SolarCity had emerged as the nation’s leading rooftop solar power company. The company’s founders, with the help of their billionaire cousin, Elon Musk, set out to be the vanguard of an age in which consumers weaned themselves from dependence on utilities for their electricity.

After piling on debt in pursuit of fast growth, the business was absorbed into Mr. Musk’s Tesla empire two years ago. And now rivals are chipping away at its primacy in installation and innovation.

In the short term, the biggest competition is coming from Sunrun, an installer of residential solar panels and energy storage that is capturing a growing amount of what had been SolarCity’s signature market.

“It is all but guaranteed that Sunrun will emerge as the top residential solar installer in the U.S.,” said Allison Mond, a senior analyst at Wood Mackenzie, which provides consulting on various issues including energy and renewables. “Tesla’s residential solar business is in rapid decline as the company has cut many sales channels.”