BuzzFeed Inc. has agreed to acquire Verizon Media’s HuffPost in a stock deal, the companies said Thursday, uniting two of the larger players in digital media as companies across the sector search for ways to jump-start growth.

The acquisition is part of a larger deal between BuzzFeed and Verizon Media, a unit of Verizon Communications Inc. Under the pact, the companies will syndicate content on each other’s platforms and look to jointly explore advertising opportunities. Verizon Media will get a minority stake in BuzzFeed as a result of the tie-up, the companies said.

Verizon Media is also making an undisclosed cash investment in BuzzFeed in addition to the stock deal for HuffPost, according to a person familiar with the matter.

Jonah Peretti, BuzzFeed’s founder and chief executive, will run the combined company. BuzzFeed will lead the search for a new editor in chief of HuffPost.

In a joint statement, the companies said BuzzFeed and HuffPost have complementary audiences and will benefit from greater scale. Financial terms for the deal weren’t disclosed, including the valuation for HuffPost.

New-media companies like BuzzFeed and HuffPost were growing at breakneck speed a few years ago, as online readers flocked to fast-paced delivery of news, lifestyle and entertainment content, and advertising dollars followed. The business became more challenging as tech goliaths Facebook Inc. and Alphabet Inc.’s Google sucked up digital ad dollars. The coronavirus pandemic delivered another blow this year.

While some publishers have found success developing revenue from subscriptions and e-commerce, many players in the sector have pursued mergers to chart a path forward. Last year, Vice Media acquired Refinery29, Vox Media acquired New York Media and GroupNine Media Inc. acquired PopSugar. BuzzFeed has explored other possible acquisitions, according to people familiar with the matter.

BuzzFeed expects to turn an operating profit this year for the first time in years, Mr. Peretti said in an interview. The company has saved money through layoffs, furloughs and other cuts.

Mr. Peretti said BuzzFeed executives will undertake a review of HuffPost’s business before making any significant moves, such as cutting staff or hiring additional employees. In a note to employees, Mr. Peretti said HuffPost attracts readers from wealthier demographics.

For Mr. Peretti, the deal with HuffPost is a homecoming of sorts. He was among the founders of the site in 2005—then called the Huffington Post—alongside Arianna Huffington and Kenneth Lerer.

It launched as a liberal alternative to popular aggregators like The Drudge Report, initially leaning on the strength of Ms. Huffington’s Rolodex of celebrity friends, whom she often convinced to blog for free. The site became an early traffic powerhouse, partly thanks to its mastery of how audiences search for news stories on Google.

“For several years, I spent my every waking moment on HuffPost and how to grow it and how to turn it into a leading media brand on the internet,” Mr. Peretti said. “So I have a deep connection to that brand because of the history. But this is not about nostalgia for me, it’s about the future, the brand and the audience.”

Verizon Media Chief Executive Guru Gowrappan said the idea for a partnership between Verizon and BuzzFeed hatched during a meeting with Mr. Peretti at the CES tech show in Las Vegas earlier this year. During the meeting, the two executives discussed ways the two companies could work together but didn’t reach an agreement on a deal for HuffPost, he said.

The talks accelerated later in the year when Verizon Media began exploring options for HuffPost. The two companies have been hashing out deal terms for several months.

“From the get-go, I was pretty clear that BuzzFeed was the right partner,” Mr. Gowrappan said.

Verizon and BuzzFeed will share ad revenue on content syndicated across each others’ sites, according to a person familiar with the matter.

In 2011, AOL bought the Huffington Post for $315 million—an eye-popping price for its day—as part of then-CEO Tim Armstrong’s bid to turn around the struggling web portal.

In 2015, Verizon acquired AOL for $4.4 billion, taking on HuffPost in the transaction. Verizon’s efforts to improve the digital media side of its business failed to gain traction, and in 2018, Verizon wrote down the value for much of that business.

Mr. Peretti co-founded BuzzFeed in 2006, after several years of studying what made things go viral on the internet. Originally dominated by light fare such as quizzes and “listicles,” the site hired prominent political journalist Ben Smith away from Politico in 2012 to build out an ambitious news division that produced work nominated for the Pulitzer Prize.

Initially, BuzzFeed focused on making money from native advertising—ads that mimic the tone and style of editorial content. But as social media companies tweaked their algorithms to make it harder for such posts to be widely viewed organically, BuzzFeed turned to more traditional forms of digital advertising, including “programmatic,” or automated auctions, as well as e-commerce and content licensing.

Fueled by venture capital, BuzzFeed enjoyed 50% annual revenue growth in its earlier years. Comcast Corp.’s NBCUniversal invested $400 million in the company, valuing it at $1.7 billion in a 2016 funding round. But growth has slowed considerably in recent years. In 2017, the company began missing its revenue targets. Meanwhile, while losses exceeded $50 million for several recent years.

This year, the pandemic pressured ad revenues, though those have begun to bounce back. The push toward profitability was helped by $30 million in cost reductions, The Wall Street Journal reported.

Write to Benjamin Mullin at Benjamin.Mullin@wsj.com and Keach Hagey at keach.hagey@wsj.com