Facebook Inc. (FB) has just made its first big move to challenge music streaming rivals, striking a deal that enables users to share videos containing licensed music from a major record label legally across its various social media platforms.

The tech giant’s multi-year agreement with Universal Music Group means that Facebook, Messenger, Instagram and Oculus Rift users will now be able to upload and share videos featuring music from the record label's huge catalog without infringing copyright laws. Facebook eventually plans to expand this offering "to enable access to a vast library of music across a series of social features," according to a press release from the two companies, which called the deal "unprecedented."

Terms of Facebook’s deal with Universal were not disclosed, although it is believed to be worth several hundred million dollars. The move, Facebook’s first with a major record label, forms part of the social network’s strategy to keep users on its website, attract advertisers and compete with streaming giants such as Alphabet Inc.’s (GOOGL) YouTube. (See also: Google and Facebook's Growing Ad Dominance Calls for Caution: Pivotal.)

Videos have soared in popularity on Facebook in recent years, although many are swiftly taken down because the social network does not have the rights to share them.

“There is a magnetic relationship between music and community building,” said Tamara Hrivnak, head of music business development and partnerships at Facebook. “We are excited to bring that to life on Facebook, Instagram, Oculus and Messenger in partnership with UMG. Music lovers, artists and writers will all be right at home as we open up creativity, connection and innovation through music and video.”

Facebook’s deal with Universal, a unit of French media conglomerate Vivendi SA (VIVEF) that holds the rights to music from artists including Jay-Z, Rihanna, Bruce Springsteen and Justin Bieber, reportedly came after months of negotiations. Bloomberg said in September that the social network had contacted several record labels about securing licensing deals. (See also: Facebook Videos Will Earn $12B by 2022: Jefferies.)

Pivotal Research analyst Brian Wieser believes that Facebook’s agreement with Universal Music should enable it to better compete with YouTube. “With this deal, Facebook has licensed content from the biggest player in the biggest genre of video on YouTube,” he said, according to Reuters

Google’s video service signed a long-term agreement with Universal Music Group and Sony Music Entertainment Corp. (SNE) several days ago.

Want to learn how to invest?

Get a free 10 week email series that will teach you how to start investing.

Delivered twice a week, straight to your inbox.