Thembi Kgatlana scored in the 25th minute, dodging two defenders before putting her shot in the upper corner and out of goalkeeper Sandra Panos' reach. South Africa, ranked 49th, was making its first World Cup appearance.
Hermoso's first penalty kick tied it in the 69th minute after South Africa captain Janine Van Wyk was called for a hand ball. She made her second in the 82nd minute, again beating goalkeeper Andile Dlamini. Lucia Garcia added the final goal for Spain in the 89th minute.
It was the second Group B match of the day: Earlier the second-ranked Germans defeated China 1-0 in Rennes.
More AP soccer: https://apnews.com/apf-Soccer and https://twitter.com/AP_Sports