ALBANY – New Yorkers can now gamble away until sunrise.

Gov. Andrew M. Cuomo has signed legislation permitting racetrack-based casinos, such as the facilities at Hamburg and Batavia, to keep their doors open until 6 a.m., instead of having to turn off the lights two hours earlier.

The measure, which comes amid declining revenues this year at most of the state’s nine racetrack-based gambling halls, also allows the casinos to offer more “free play’’ as a way to entice bettors to spend more of their own money on the betting machines.

The law permits tracks to keep their gambling facilities, known in the industry as racinos, open 20 hours per day. But until Tuesday, they had to shut their operations down at 4 a.m. They open at 10 a.m. each day.

The new law takes effect immediately.

“The purpose of this bill is to enhance the revenues of video lottery gaming facilities in New York,’’ states a legislative memo accompanying the bill.

At the time of the bill’s passage in June, critics said the provisions would lead to more problem gambling in the state.

Precisely how much additional money is projected to come to the tracks – and the state, which gets a take of the wagers – was not spelled out in the bill or legislative memo.

Hamburg and Batavia are two of nine racetracks that are permitted in New York to have video lottery terminals, which as far as most bettors are concerned are the same as slot machines. The facilities cannot offer table games, like poker; the seven new commercial casinos authorized by voters last fall will be able to offer both real slots and table games.

The expanded “free-play’’ provision in the new law is meant to bring more bettors to the track casinos, or to keep existing patrons gambling longer during each visit. The facilities give free bets to regular patrons, a common practice in the casino industry.

The new law allows the tracks to increase from 10 percent to 15 percent the amount of free-play allowances of the total wagers at the facilities. In the last three months, the nine track facilities issued $53 million in free-play allowances. How that specifically translated into additional revenues is uncertain.