(Reuters) - Satellite radio company Sirius XM Holdings Inc will buy online music service Pandora Media Inc in a $3.5 billion all-stock deal that will help it battle growing competition from streaming rivals Spotify and Apple Music.

Sirius XM, controlled by media mogul John Malone’s Liberty Media Corp, has built a name supplying more than 175 channels to car drivers, but has largely trailed Pandora, Spotify Technology SA and Apple in mobile and streaming content.

Monday’s deal gives the pair a market value of about $34 billion, topping Spotify’s $31.2 billion and follows through on Sirius’ purchase of a 15 percent preferred-stock stake in Pandora for $480 million last year.

“We view the read through to Spotify as slightly negative as it could face a stronger competitor in the U.S. while at the same time one of the only large swaths of ad-supported listeners in the fast-maturing U.S. goes off the market,” SunTrust analyst Matthew Thornton said.

Sirius shares, however, fell 4.2 percent to $6.69 as investors worried the company had overpaid.

Shares in Pandora, which has posted losses for at least the past eight quarters, rose 6.5 percent to $9.68 in early trading, slightly below an offer value of $10.05 based on Sirius’ Friday closing price.

The deal, worth $2.68 billion at the offer price, is expected to generate more than $7 billion in expected pro-forma revenue in 2018. Analysts said the two businesses were largely complementary.

“SIRI cannot offer on-demand radio, and cannot offer customization, and Pandora offers both,” said Michael Pachter, an analyst with Wedbush Securities in Los Angeles.

“Sirius can merge Pandora’s radio business into its satellite subscription business, and can also begin to offer on-demand to its large installed base of satellite subscribers.”

Pandora has been trying to mark its position in an industry where competitors are routinely adding new features, giving away discounts and offering more content, including interviews with popular musicians.

Pandora shareholders will get a fixed-exchange ratio of 1.44 newly-issued Sirius XM shares for each share held.

If the deal is terminated, Pandora will have to pay either $52.5 million or $105 million, depending on the circumstances, the company said in a filing.

Sirius XM said following the deal, which is expected to close in the first quarter of 2019, Pandora stockholders will own 8.6 percent of the pro forma company on a fully diluted basis.

Sirius XM Chief Executive Officer James Meyer said on a conference call that the company had been in talks with Pandora even before its Chief Executive Officer Roger Lynch took up the position in August last year.

“We had a conversation 15 months ago. We couldn’t reach an agreement on value quite honestly,” Meyer said.

Allen & Co LLC and BofA Merrill Lynch are financial advisers to Sirius XM, while Centerview Partners LLC, LionTree Advisors LLC and Morgan Stanley & Co LLC are financial advisers to Pandora.