NEW YORK — “Guardians of the Galaxy” became the summer’s top-grossing movie at the North American box office with a $17.6 million weekend that narrowly bested the young adult melodrama “If I Stay,” while the long-delayed “Sin City” sequel, “A Dame to Kill For,” flopped.

The Marvel space adventure passed “Transformers: Age of Extinction” to become the summer’s biggest domestic hit with a cumulative total of $252 million. The film, released by Disney, was an unlikely August sensation that helped the box office rebound somewhat after big-budget sequels like “The Amazing Spider-Man 2″ and “How to Train Your Dragon 2″ failed to ignite the multiplexes.