DraftKings CEO Jason Robins walks out of court after a hearing in New York in 2015. Daily fantasy sports companies DraftKings and FanDuel will merge late next year. REUTERS/Nate Raymond

DraftKings and FanDuel, the two largest companies in the daily fantasy sports market that exploded into national consciousness last fall with a crush of television advertising that brought legal scrutiny across the country, have agreed to merge, the companies announced Friday morning.

Pending approval by the Federal Trade Commission, the merger will close in late 2017. Financial terms of the merger were not disclosed. DraftKings CEO Jason Robins will serve in the same capacity at the unnamed merged company, according to a news release, and FanDuel CEO Nigel Eccles will become chairman of the board.

The merger will allow the cash-needy companies to combine resources and eliminate redundant spending as they wage legal, lobbying and public relations battles in multiple states over the legality of the daily fantasy industry. Government officials in more than a dozen states — including Nevada, Arizona and Texas — have either outright banned daily fantasy or issued legal opinions skeptical of the industry’s legality. Last month, DraftKings and FanDuel each agreed to pay $6 million to the New York attorney general’s office to settle claims they used false and deceptive advertising.

Eccles, a Northern Irish entrepreneur, for all intents and purposes invented the daily fantasy industry in 2009, with a company that offered a twist on fantasy sports, which traditionally involved players building their own virtual teams of professional athletes and then competing for an entire season to see whose players performed best. FanDuel offered fantasy competitions that ended in a week, or even a day.

In 2012, Robins and two friends founded DraftKings in Boston, and over the next three years the two companies enjoyed meteoric growth in a booming industry, as millions of sports fans plopped down entry fees ranging from a few dollars to a few thousand dollars in the hopes of winning a cash windfall hours later. Professional sports leagues ponied up millions as partners, and DraftKings and FanDuel each saw valuations surpass $1 billion. Then a flood of television advertising in late 2015 brought the attention of lawmakers and regulators in multiple states with questions about daily fantasy’s legality.

While a 2006 federal law banning online gambling included sports wagering, it contained a loophole permitting fantasy sports; however, that was before daily fantasy’s inception. Last fall brought a wave of legal opinions from attorneys general and state regulators that daily fantasy was, in fact, gambling. That October, Nevada gaming regulators ordered the sites to stop operating in the state. A month later, New York Attorney General Eric Schneiderman announced his office had also determined daily fantasy was illegal gambling. In December, Illinois Attorney General Lisa Madigan followed suit.

In 2016, the companies have won some victories — in New York a new law defined daily fantasy as legal — but the expensive legal and lobbying campaigns took their toll, as both companies laid off workers. The merger will allow the companies to combine their efforts, while also focusing on trying to grow. DraftKings and FanDuel, combined, have about 5 million users, according to company figures, while an estimated 57 million people in North America play some type of fantasy sports.

Robins, in a statement, said the merger “will help us advance our goal of building a transformational global sports entertainment platform.”

“Being able to combine DraftKings and FanDuel presents a tremendous opportunity for us to further innovate and disrupt the sports industry,” Eccles said.