MGM Resorts, the casino company, has reached a deal to buy Yonkers Raceway and its attached casino for $850 million, the two companies announced on Monday. The deal is MGM’s first foray into New York, a market that is expected to consider the legalization of sports wagering in the next several years. The casino at Yonkers, called Empire City, has 5,222 slot machines and is the closest competition to the highest-grossing casino on the East Coast, Resorts World at Aqueduct racetrack. Yonkers has been owned by the Rooney family for 46 years. In November, the family announced that it had hired investment advisors at J.P. Morgan Chase to assist in arranging a sale of the track and casino. “We have been a partner of New York state and its communities for 46 years, and it was important to us that we identify an entity that could build on the strong foundation we have established and bring our vision to fruition,” said Tim Rooney, the chief executive of Empire City, in a statement. “We are confident we have found that in MGM Resorts, one of the premier gaming entities in the world.” For the last 12 months, handle on Empire City’s slot machines has been nearly $10 billion, according to figures from the New York Gaming Commission. Net win from the handle was $598.5 million, according to the commission, with nearly half of that amount going to the state’s education fund. Under recent legislation, New York will begin to consider offering full casino licenses to its existing racinos as early as 2021. That could enable Empire City to also offer table games such as blackjack and craps. Yonkers Raceway opened in 1899, and the track was one of the most popular harness racing spots in the U.S. during that sport’s heyday. However, handle on harness races dropped off considerably in the 1980s and 1990s, and the sport’s existence is closely tied now to the awarding of casino licenses to harness track operators. Along with its landmark Las Vegas property, MGM owns the Borgata in Atlantic City, and it plans to open a $1 billion casino in Springfield, Mass., this summer. “This acquisition represents an excellent opportunity to further solidify our presence on the East Coast, and in particular, expand our reach into the high-density New York region,” said Jim Murren, the chief executive of MGM Resorts, in a statement.