The work, created by Adam & Eve/DDB, shows the pair dancing through the streets of Buenos Aires with models Andreea Diaconu, Anna Ewers, Imaan Hammam and Naomi Shimada, and singer/songwriter Andrea Valle.
The film begins Olsen looking bored as she dances with a man. Then another woman taps the man on the shoulder, the music turns upbeat and the two women enjoy dancing together.
They spill out onto the streets and are joined by other women in the sunshine. The film also shows the dancing breaking the frame and ends with Ryder emerging from the shadows to dance with Olsen.
The work is for the brand's spring 2018 collection which launches in stores tomorrow.
The ad was created by Genevieve De Rohan Willner and Selma Ahmed. It was directed by Gustav Johansson through Iconoclast, and media planning and buying was handled in-house.
Pernilla Wohlfahrt, H&M’s design director, said: "It was wonderful to see how all the women on set were able to express their own personalities through the strong yet relaxed shapes of the spring collection. The voluminous pieces in particular, moved so beautifully in the dance sequences."