Spain were the first to threaten, less than a minute in, with Becky Sauerbrann getting her head in the way to block Patri Guijarro's powerful shot.
Moments later, the States had their first penalty as Mario Leon caught Tobin Heath inside the box and Rapinoe sent Sandra Panos the wrong way with a shot into the bottom left-hand corner of the net in the fifth minute.
But Spain quickly responded, punishing a defensive howler at the back. Sauerbrann was dispossessed by Lucia Garcia after an unwanted short pass from goalkeeper Alyssa Naeher, and when the ball fell for Hermoso she lifted a fine shot into the right corner of the net.
Rapinoe almost had the Americans straight back in front when she met a sweeping ball from Alex Morgan, but they soon learned they would be made to work hard by a Spanish team that grew in confidence as the game went on.
The pressure began to build again early in the second half but Rose Lavelle sent the best chance narrowly over the crossbar.
Instead, the States would need another spot-kick, their second coming when Virginia Torrecilla caught Lavelle in the box.
Morgan initially stepped forward, looking for a sixth goal that would put her clear in the tournament scoring charts.
But, after a lengthy video review which led to a six-minute stoppage in play, it was Rapinoe that took responsibility.
Panos guessed right this time as Rapinoe picked the same spot, but the result was the same with the goalkeeper unable to get down in time.
Rapinoe was in the mood for a hat-trick. Out on the left, she hit an audacious effort with the outside of her right boot and watched it sail narrowly wide of the far post from a tight angle.
A third would have been harsh on Spain, whose performance will have been noted by those aiming to dethrone the Americans.
Sweden squeeze through
Stina Blackstenius fired Sweden into the quarter-finals of the Women's World Cup but they needed a penalty save from Hedvig Lindahl to edge out Canada 1-0 in Paris.
A slow-burner of a game finally came to life in the second half, with Kosovare Asllani at the heart of it.
It was the former Manchester City midfielder who raced downfield and played an inch-perfect pass for Blackstenius to open the scoring with the game's first shot on target, just shy of the hour mark.
But it was also Asllani who was penalised for handball eight minutes later, before Lindahl denied Janine Beckie from the spot.
Sweden go through to face Germany.