Barstool Sports, the controversial sports and pop-culture blog, agreed to sell a 36% stake to casino operator Penn National Gaming for about $163 million, the latest sign of convergence in sports, media and gambling.

Penn National will increase its ownership to about 50% after three years with a further investment of about $62 million, the companies said Wednesday. Penn National will be Barstool Sports' exclusive gaming partner for as long as 40 years. The cash and preferred stock deal values Barstool Sports at about $450 million.

Penn shares closed up 10.72% ($2.81) to $29.02 in New York.

The purchase gives Penn a popular brand name to reach new customers and market its sports-wagering business nationally. Legal sports betting has soared since the U.S. Supreme Court overturned a mostly nationwide ban two years ago. Fourteen states now have sports betting, while seven more have approved it but aren't yet taking wagers.

The deal follows other media-betting partnerships, including an online sports-wagering venture that Fox Corp. launched with the parent of PokerStars, and ESPN's partnership with Caesars Entertainment Corp. to open a TV studio for betting fans in the Linq casino in Las Vegas.

The sale also represents a profitable partial exit from Barstool for Hollywood executive and investor Peter Chernin, who acquired a majority stake in the business in 2016. Entities affiliated with his Chernin Group will own 36% of Barstool after the deal, with the remaining 28% held by Barstool employees.

Jon Kaplowitz, head of Penn Interactive, said the company will be adding the Barstool name to as many as 20 casino sportsbooks in states that include Pennsylvania, Michigan and Illinois by the end of the year. Barstool writers and commentators will make appearances at Penn properties, creating events that bring in a younger audience.

A new Barstool-branded betting app will be in place by this year's pro football season, Kaplowitz said. Under the deal, Penn won't have to share revenue from sports bets with Barstool. Advertising deals that Barstool has with FanDuel and other betting brands will end by football season.

Barstool's controversial content in the past gave Penn cause for concern, but Kaplowitz is confident it can avoid trouble.

"We've designed the deal where the key Barstool employees are now major Penn shareholders, so we're all fully aligned to ensure that we're maintaining our relationships with our regulators," he said.

Barstool was founded in 2003 by Dave Portnoy, a blogger who remains involved. The company has expanded into podcasting.

In late 2017, ESPN canceled a show hosted by some the site's personalities following social-media complaints that Barstool's content was insulting to women. The site has a daily feature with photos of a scantily clad woman called Smokeshow and in the past rated the attractiveness of teachers who were charged with having sex with their students.

The company recently reached a settlement with the National Labor Relations Board to delete tweets in which Portnoy threatened to fire people who talked to union activists.

Penn, based in Wyomissing, Pa., got its start in 1972 with a single horse track it still operates nearby. The company has expanded largely through acquisitions and now operates 41 casinos or tracks across the country. Its Pennsylvania casinos operations are the Hollywood Casino at Penn National Race Course in Grantville, and the Meadows in Washington. It also has operations in Freehold, Clementon, and Toms River, N.J.

States that have approved sports betting generally give preference in awarding licenses to existing casino and track owners. Penn’s main brand, Hollywood Casino, doesn’t resonate with sports bettors, however, and chief executive officer Jay Snowden said last year that he was looking for a media partner.

Barstool was advised on the sale by Moelis & Co.