SiriusXM has agreed to invest $480 million in Pandora, giving it a 19 percent stake in the streaming music company.

The investment ends months-long speculation that SiriusXM would buy Pandora outright. It’s not clear why plans changed, but SiriusXM says the cash injection “will allow Pandora to make targeted investments” — though it doesn’t elaborate on what those might involve.

Pandora CEO Tim Westergren says the influx of money will give his company “the flexibility we need to attack what is becoming a larger and larger opportunity as digital music enters a new golden age."

SiriusXM needed a way into streaming, Pandora needed cash

Pandora has been around for nearly two decades, but it’s been struggling to compete in recent years with newcomers like Spotify and Apple Music that offer much richer music services. Pandora struck back with its own full-on streaming option in March, but it faces a tough battle trying to get people to switch back from competitors, which offer similar and often more mature services, or to upgrade from its largely free radio service.

For SiriusXM, the investment provides the satellite radio company with a way into different parts of the streaming music game. SiriusXM doesn’t have a traditional presence there yet (though you can get an internet-only subscription to its radio service), and streaming services pose a real threat to the satellite radio business. Starting up its own Spotify-like service would be a tough and time-consuming option, so it makes sense to find a way in through an investment in a struggling but notable player while there’s still plenty of space for the market to grow.

At the same time, Pandora is raising a little extra cash by selling Ticketfly, which it bought in a deal initially valued at $450 million in 2015, for just $200 million to Eventbrite. Pandora now plans to work with Eventbrite to integrate ticket sales, rather than running a ticketing service on its own.

Correction June 9th, 11:05AM: SiriusXM offers an online subscription to its radio service; this story previously said that it had no online streaming presence.

Clarification June 12th, 2:45PM ET: A representative of Pandora reached out to note that the $450 million purchase price of Ticketfly ultimately closed at $335.3 million because Pandora’s stock — a component of the deal — fell in the three weeks between when the deal was announced and when it closed.