ESPN has agreed to a 10-year deal with Penn Entertainment to create a betting brand called ESPN Bet.

Penn will operate the online sports book and pay ESPN $1.5 billion in cash for the use of ESPN’s name, marketing, “access to ESPN talent.” 

Penn also will give ESPN options to buy $500 million in Penn stock.

As part of the transaction, Penn is selling Barstool Sports, a sports media company, back to its founder, David Portnoy. 

Penn was struggling to compete with DraftKings and FanDuel under the Barstool Sportsbook brand. 

The deal allows ESPN to rake in a large sum of money related to gambling without becoming a sports book itself.