The firms also said they were working together on new music products, a sign Facebook has set its sights on challenging YouTube.
UMG said the deal was “unprecedented”.
Terms were not disclosed.
Universal represents artists such as Taylor Swift and Jay-Z. The company has previously pushed Facebook to remove posts, including covers of its artists’ songs.
Universal Music Group’s executive vice president of digital strategy, Michael Nash said: “Together, Facebook and UMG are creating a dynamic new model for collaboration between music companies and social platforms to advance the interests of recording artists and songwriters while enhancing the social experience of music for their fans.”
In a news release, the companies said that “in time” users will also be able to access a “vast library” of music.
The licensing deal covers Facebook, as well as Instagram and Oculus. The firms are also working on products for Facebook’s messaging service.