Spain gave the U.S. all they could handle in their Round of 16 matchup on Monday, but some big mistakes by the Spanish helped the U.S. to a 2-1 victory and advance to the quarterfinals to face host country France.

The game started off well for the U.S., with Tobin Heath drawing a penalty in the opening minutes to give the U.S. an early chance to take the lead. Megan Rapinoe stepped up to the penalty spot and fired into the left side of the net while the Spain keeper went the other way, putting the U.S. on top 1-0.

USWNT: Ranking The Best Players Of All-Time

However, the lead didn’t last long, when a miscommunication and a poor decision between U.S. goalkeeper Alyssa Naeher and defender Becky Sauerbrunn led to losing the ball near the 18-yard box, where Spain’s LucÍa Garcia found Jenni Hermoso, who chipped the ball over Naeher to tie the match at 1-1.

The game was back-and-forth throughout after the early goals, with neither team threatening muchs. A breakthrough finally came late in the second half for the U.S., when another error by Spain gave the U.S. a penalty kick chance after Rose Lavelle was fouled in the box while chasing down the ball. A VAR review confirmed the call, and Rapinoe stepped up to the spot again, driving the ball to the left again, beating the diving Spain keeper for the 2-1 advantage in the 76th minute.

The final 15 minutes plus stoppage time saw Spain have a few chances to even the score, but the U.S. defense held strong to preserve the victory.

The U.S. will now face France in the quarterfinals on Friday, the host nation and other World Cup favorites. The game takes place in Paris and can be seen on FOX at 1 p.m. MT

Follow Fan Insider on Facebook and on Twitter.