The measure will make San Francisco the first U.S. city to forbid offering a free toy with meals that exceed prescribed levels of calories, sugar and fat.
The ordinance requires restaurants to provide fruits and vegetables with all meals that come with toys for children.
The ordinance, which takes effect in December, says restaurants may include a toy with a meal if the food and drink combined contain fewer than 600 calories, and if less than 35 percent of the calories come from fat.
"We are extremely disappointed with today's decision. It's not what our customers want, nor is it something they asked for," McDonald's spokeswoman Danya Proud said.