CHICAGO (AP) — The Chicago City Council, forced by a federal judge to allow gun sales in the city, approved an ordinance Wednesday that dramatically limits where gun stores can open and puts owners on alert that officials will be watching every time they sell a gun.

Mayor Rahm Emanuel and council members made it clear that the only reason they were voting to permit gun stores after decades of a ban was because of the ruling earlier this year that the ban was unconstitutional. The ruling followed a 2010 U.S. Supreme Court decision that invalidated the city's handgun ban.

"I really wish the Supreme Court justices who opened up the floodgates on guns had to take the calls I get at 2 o'clock in the morning from police sergeants and lieutenants about shootings," Alderman Will Burns said before the 48-0 vote. "This is the best we can do and I'm holding my nose and voting for it."

Chicago for decades has been at the center of the national debate over gun violence and gun control. After the Supreme Court's 2010 ruling on handguns, a federal appeals court in Chicago ruled in 2012 that Illinois' last-in-the-nation ban on concealed weapons was unconstitutional. Then came the January.

Some of the provisions will almost certainly trigger a legal challenge, including a requirement that all gun sales be videotaped and another that gun owners open their books for inspection by police.

The ordinance also prohibits gun stores in 99.5 percent of the city by confining sales to specific areas and prohibiting stores within 500 feet (150 meters) of schools and parks.

"It's actually an ordinance to prevent gun shops," said a gun rights advocate, Richard Pearson, executive director of the Illinois State Rifle Association.

Emanuel disagreed, adding that the city's law department examined the ordinance and determined that it is on solid legal ground.

The mayor, while not welcoming a lawsuit, suggested it was important to pass the toughest ordinance possible.

"You have to do what you think is right," he said.

The gun ordinance also addresses what police and others believe is a big reason for what they say is a flood of illegal guns into Chicago and why the city's police officers seize more illegal guns than any police department in the United States: The sale of guns by so-called straw purchasers, who transfer them to people who are not legally allowed to buy and possess firearms.

The ordinance allows buyers to purchase no more than one gun every 30 days.