Barry Diller’s IAC/InterActiveCorp. has reached a roughly $2.7 billion deal to buy magazine publisher Meredith Corp., a bet on online publishing that will combine brands such as People, Better Homes & Gardens and Investopedia.

As a result of the deal, Des Moines-based Meredith will become part of Dotdash, IAC’s digital-publishing division, the companies said Wednesday. The company will be called Dotdash Meredith and run by Dotdash Chief Executive Neil Vogel, they said. The deal is expected to close by year’s end.

The...

Barry Diller’s IAC/InterActiveCorp. has reached a roughly $2.7 billion deal to buy magazine publisher Meredith Corp. , a bet on online publishing that will combine brands such as People, Better Homes & Gardens and Investopedia.

As a result of the deal, Des Moines-based Meredith will become part of Dotdash, IAC’s digital-publishing division, the companies said Wednesday. The company will be called Dotdash Meredith and run by Dotdash Chief Executive Neil Vogel, they said. The deal is expected to close by year’s end.

The $42.18-a-share acquisition of Meredith, which earlier agreed to sell its local-TV business to Gray Television Inc., would add an array of lifestyle publications like Real Simple, Allrecipes and InStyle to Dotdash’s existing portfolio, which includes Brides, Serious Eats and TripSavvy.

“They are perfectly aligned,” Mr. Diller, IAC’s chairman, said of the properties of IAC and Meredith, in an interview. “One will help the other.”

The Wall Street Journal had reported the companies were in advanced talks last month.

“Nowhere else will you find such a premium portfolio of media assets under one roof,” Tom Harty, chairman and CEO of Meredith, said in a statement. “We are thrilled to join forces to accelerate Meredith’s digital future.”

The deal will also bulk up IAC’s portfolio of websites, which has shrunk recently after the company moved to spin off online-dating behemoth Match Group Inc. and video-hosting and sharing platform Vimeo Inc.

During a call announcing the Meredith acquisition Wednesday evening, IAC CEO Joey Levin said the deal, while large, still leaves IAC with plenty of cash for other potential deals.

Acquiring online companies and later spinning them off has long been part of New York-based IAC’s playbook. The company, which began as a hybrid media/electronic-retailing business that included the Home Shopping Network, emerged in the early 2000s as a voracious buyer of internet companies, many of which were eventually spun off and are now publicly traded. Beyond Match and Vimeo, the businesses once under IAC’s umbrella include Expedia Group Inc., Ticketmaster and LendingTree Inc.

Digital publisher Dotdash, which would house the Meredith properties, currently reaches about 100 million online consumers monthly through 14 media brands in health, finance and lifestyle, IAC said. The combined company, which would include Meredith’s 40-plus brands, would reach more than 175 million online consumers monthly, the companies said.

“Meredith is the largest magazine media company in the world and has very solid roots in print,” Samir Husni, a leading magazine consultant, said in an interview. “Will IAC have the same focus on print that was placed by the current Meredith team, or will they put greater emphasis on data and digital expansion? Meredith has a very good database; it will be better used with the digital power of IAC.”

Mr. Vogel, in the conference call to discuss the proposed deal, said print would continue to be part of the mix going forward, investing on top performing titles and focusing on profitability.

The decision to sell marks an abrupt turnabout for Meredith, which just a few years ago had bet on the future of the magazine business when it agreed to buy Time Inc. for $1.85 billion.

Meredith later sold off high-profile Time Inc. titles such as flagship brand Time magazine, Fortune and Sports Illustrated. It focused on leveraging the brands of other Time Inc. publications such as People, which it felt had room to bring in more money. It also created several new magazines in recent years, including Magnolia Journal, a lifestyle publication launched in 2016 with home-renovation celebrities Chip and Joanna Gaines.

Despite those moves, Meredith has struggled with significant debt as newsstand and print-advertising revenues have faced serious challenges, a situation worsened by the pandemic.

Write to Maria Armental at maria.armental@wsj.com and Jeffrey A. Trachtenberg at jeffrey.trachtenberg@wsj.com