After years of on-again, off-again talks, the satellite radio company on Monday agreed to buy internet radio streamer Pandora for $3.5 billion.

The all-stock deal takes SiriusXM outside the car for the first time and gives it firmer footing to go up against Apple Music and Spotify in the increasingly competitive global battle to become the dominant music streamer.

While the deal, at about $10.14 a share, was below the $15 price that was bandied about a year ago, it will fall to Greg Maffei, the chief executive of Liberty Media, SiriusXM’s controlling shareholder, to prove the deal is a bargain.

Pandora’s active users fell to 71.4 million at the end of the second quarter from 76 million a year earlier.

The Oakland, Calif., streamer did manage to grow its paid subscriber base 9 percent, to 5.98 million, over the same period.

Last year, Sirius invested $480 million in Pandora in exchange for nearly a 20 percent stake in the company.

Sirius’ shares fell 10.3 percent on Monday, to $6.26.

Pandora’s stock slid 1.2 percent to $8.98.

“It’s an expensive deal but it helps to solve some strategic holes for Sirius and Pandora,” said BTIG analyst Brandon Ross, who noted that there is no collar agreement on the deal, so Sirius may have paid less, around $9 or $10.

That range squares with the $10-a -hare price that Maffei was looking to pay in 2016.

Under the deal, Pandora shareholders would swap each share for 1.44 newly issued shares of Sirius.

Sirius has 36 million paying subscribers in the US and Canada — and roughly 23 million trial listeners who are recent car buyers on a trial subscription.

Ross said the companies have to produce some healthy organic growth — and that Liberty would likely move to combine Sirius/Pandora with its 35 percent stake in Live Nation, the live music and events company to improve its odds of successfully battling rivals.

Swedish music titan Spotify has more than 83 million subscribers and Apple Music has more than 50 million paid and free subscribers.

Tidal, Jay-Z’s streamer, is “getting aggressive in the space with exclusive content” and “YouTube/Google Play is becoming increasingly relevant” with its paid YouTube Premium and SoundCloud, which has 175 million users globally, Aegis Capital Corp. analyst Victor Anthony said.

“I think there’s the larger existential issue,” offered BTIG’s Rich Greenfield. “Sirius is saying the internet is important to its future. It highlights a larger vulnerability.”

It’s for that reason that Sirius has been circling Pandora for some time, even though the free, ad-supported firm has been blowing through cash since it went public in 2011.

Sirius’ investment last summer came after the two firms couldn’t agree on a price for Pandora. At the time, sources put Sirius’ offer at between $15 and $16 a share but Pandora’s board and then-CEO Tim Westergren was looking for $20 a share.

“It was ego,” said Greenfield. “Westergren had an inflated sense of what his company was worth and he was wrong. The point is, they should have sold it a long time ago.”