The girl, whose identity has not been released, climbed over the safety wall on top of the apartment building to hang from a girder during a photo shoot with a friend.
But after attempting the dangerous pose, she was unable to climb back onto the roof.
Her friend alerted police and officers from the Urban police together with those from the Catalan regional force, los Mossos d'Esquadra, came to the rescue.
Police said they found her frozen by vertigo on the narrow ledge suffering a panic attack and tweeted a photograph of the foolhardy teenager and the moment she was rescued.
She was lifted to safety and returned shame-faced to her parents.