The two best-known home-shopping TV networks in America, QVC and Home Shopping Network, agreed to merge Thursday, forming a new retail juggernaut as part of an all-stock deal valued at about $2.1 billion.

Under the agreement, QVC’s parent firm, Liberty Interactive, the holding company founded by billionaire media mogul John C. Malone, would buy the remaining 62 percent of HSN that it does not already own. The entity would then combine under QVC Group, though HSN would continue as a separate brand.

The transaction is set to be finalized by the end of the year, pending regulatory and shareholder approval. It would create the largest television commerce company in the world, with $14 billion dollars in revenue, and become the third-largest e-commerce company in North America, lagging behind only and Walmart, according to the digital research firm eMarketer.

QVC and HSN both found loyal followings among early cable television viewers in the 1980s but have more recently faced challenges adapting to the online age. Increasingly, they must appeal to cord-cutters who have given up their cable television subscriptions in favor of watching videos on tablets, computers and smartphones.

Executives argued that the two networks would be stronger as one. Both offer sales over multiple cable channels and digital platforms and have developed strong niches. With its chipper hosts, QVC has made several beauty and fashion pitch-people household names, while HSN owns popular home and apparel lifestyle brands such as Ballard Designs, Frontgate, Garnet Hill, Grandin Road and Improvements as part of its Cornerstone unit.

Together, the two companies count 23 million customers — though there may be some overlap — and 2 billion website visits, and they combine for 320 million packages shipped annually.

QVC and HSN employ about 27,000 team members in eight countries.

In a letter to employees, QVC chief executive Mike George, who will lead the new company, said the combination should be able to generate between $75 million to $110 million in annual cost reductions within the next three to five years, and that money would be used to fund new innovations.

“We will be able to operate more efficiently, by combining technology platforms where appropriate, leveraging our joint service and supply chain networks, eliminating redundant corporate and support services, and negotiating volume based discounts with our partners,” he wrote.

George warned, however, that there would probably be “headcount reductions as we address areas of overlap, which will likely affect both companies.”

For HSN, the deal would mean accessing a bigger market and strengthening its existing portfolio.

“Joining the QVC Group will give us instant access to global consumer markets, a leadership team with deep expertise and a global perspective, and the opportunity to further strengthen our content-based brand portfolios in a changing retail landscape,” said Arthur C. Martinez, HSN’s chairman and a former chief executive at Sears.

Analysts said the companies will continue to face competition from the likes of and a reinvigorated Walmart, which has begun a major online push.

“Both brands already have large customer bases, but the real question will center on how they plan on locking their customers into the HSN-QVC ecosystem and stop them from going to competitors like Amazon,” said Tom Caporaso, chief executive of Clarus Commerce, an online commerce firm. “By building a premium loyalty program like Amazon Prime, the new converged brand could start to become a major threat to Amazon’s visions of total domination of the industry.”

Executives said they were excited to share best practices and leverage one another’s capabilities.

Added Martinez in a statement: “We have both been innovators in a growing and dynamic retail environment with a unique vision of what shopping should be, and as new technologies continue to change our everyday lives, together we can develop the next generation of shopping for the next generation of consumers.”