Top daily fantasy sports companies FanDuel and DraftKings agreed to halt their business in New York on Monday, betting on a legislative path to make the games legal after a months-long fight with the state's attorney general.

New York Attorney General Eric Schneiderman said the companies agreed to immediately stop operating paid contests in the state. An appeal of an injunction against the two companies is slated to be heard by the state's Appellate Division in September.

The settlement means that the companies would not have to pay any fines or other penalties related to the gambling charges, even if they are found to have been operating illegally.

"This is a decisive and important victory for the rule of law in New York state," Schneiderman said at a press conference. "No company or individual no matter how powerful or well financed is above the law."

New York is one of the largest markets for daily fantasy sports in the United States. According to court filings, the state was DraftKings' second biggest by revenue in 2014.

Under the settlement, if daily fantasy sports are legalized in New York this year, the gambling claims against the companies will be dropped. The privately-held companies could still face charges for false advertising or consumer protection issues. 

There have been bills proposed in New York's state legislature to make the games legal, one of which was recently attached to the state budget. That means the matter could be considered as soon as this week.

The settlement "brings this issue to the forefront and I look forward to working with my colleagues in the Senate and Assembly, and the governor, to see it addressed during the budget process," New York state Senator John Bonacic, who proposed one of the bills, said in a statement.

That bill contains a one-time registration fee of $500,000 that daily fantasy sports companies would have to pay in order to operate in New York, which could lock out some smaller competitors of DraftKings and FanDuel.

Fantasy sports started in 1980 and surged in popularity online. Participants typically create teams that span an entire season in professional sports.

Daily fantasy sports, a turbocharged version of the season-long game, have exploded in popularity over the past decade. Players draft teams in games played in just one evening or over a weekend.

This enabled fans to spend money on the games with a frequency that critics say is akin to sports betting.

The multibillion-dollar fantasy sports industry has drawn increased attention from state regulators over the past year, with the attorneys general of New York, Illinois and Nevada challenging their legality and whether the games amount to gambling.

Schneiderman in November declared the games to be illegal gambling and demanded that the companies stop taking bets in New York.

But a New York state judge issued an injunction against the companies in December, which was suspended shortly thereafter by a higher court.

"New York is a critical state for FanDuel," the company said in a statement. "While it is disheartening for us to restrict access to paid contests in our home state, we believe this is in the best interest of our company."

DraftKings said it would continue to work with state lawmakers to enact legislation to ensure the games are deemed legal.

The companies have raised hundreds of millions of dollars from investors including Fox Sports, Major League Baseball, the National Hockey League, KKR & Co LP, Raine Group, Google Capital and the venture arms of Time Warner Inc and Comcast Corp.

DraftKings also partnered with Major League Baseball to advertise in ballparks while FanDuel signed partnerships with several NFL teams.