Two northern New Jersey towns besieged by commuters were warned to put the brakes on ordinances banning out-of-town traffic on local roads, the state's top law enforcement official disclosed on Wednesday.

State Attorney General Gurbir Grewal told an Assembly committee he advised officials in Leonia and Weehawken in March not to enforce ordinances aimed at curbing the traffic crunch from New York commuters.

The Leonia ban made national news late last year after local officials, facing gridlock they blamed on GPS navigation apps, tried to prevent non-residents from using their side roads as shortcuts.

Appearing in front of the Budget Committee Wednesday, Grewal responded to a question about the controversy from Assemblyman Gordon Johnson, D-Bergen, by stumbling into a reference to the George Washington Bridge scandal.

"This is a byproduct of Google Maps and Waze, so when you're in a traffic jam -- well, maybe I'll stay away from the traffic jams at the bridge," he said, prompting laughter in the committee room.

"When you're going to the bridge and traffic is building up, Waze is directing people to go through Leonia and some side streets and that's creating some problems locally that the local police department has to deal with," Grewal, a former Bergen County prosecutor, said.

Leonia passed an ordinance in December prohibiting non-residents from driving on about 60 of the township's residential streets during peak traffic hours. Under the law, violators faced a $200 fine.

In February, officials in the Hudson County town of Weehawken approved a similar measure to alleviate overflow traffic from the Lincoln Tunnel.

But amid outcry from neighboring towns and a few legal challenges, the Attorney General's Office in March advised officials in those towns that their bans were illegal.

In a letter to an attorney for Leonia, Grewal advised town officials "immediately refrain from enforcing them," according to a copy obtained by NJ Advance Media on Wednesday.

For one, such laws are subject to review by the state transportation commissioner, the attorney general wrote. Additionally, a 1955 formal opinion from the Attorney General's Office already forbids local officials from restricting through traffic on their roads.

Local officials in the two towns could not be reached for comment Wednesday evening, but Grewal told state lawmakers they had "agreed to stand down on the enforcement" of the ordinances.

Signs prohibiting non-resident traffic remain posted in Leonia. The attorney general said Wednesday his office was "in discussions with (the towns) to get an appropriate fix."

S.P. Sullivan may be reached at ssullivan@njadvancemedia.com. Follow him on Twitter. Find NJ.com on Facebook.