Spotify will pay more than $20 million to music publishers to settle a long-running and complex dispute over licensing, according to an agreement announced on Thursday between the streaming service and the National Music Publishers’ Association, a trade group.

Exact terms of the deal were not disclosed. But according to several people involved with the settlement on both sides, who spoke on the condition of anonymity to discuss confidential financial terms, Spotify will pay publishers between $16 million and $25 million in royalties that are already owed but unpaid — the exact amount, these people said, is still undetermined — as well as a $5 million penalty. In exchange, the publishers will refrain from filing copyright infringement claims against Spotify.

The settlement concerns mechanical licensing rights, which refer to a copyright holder’s control over the ability to reproduce a musical work. The rule goes back to the days of player-piano rolls, but in the digital era mechanical rights have joined the tangle of licensing deals that streaming services need to operate legally.

Over the last year, it emerged that Spotify — which has long trumpeted itself to the music industry as a law-abiding partner — had failed to properly obtain the mechanical licenses for large numbers of songs.