World Cup hosts Brazil set up a meeting with Chile in the round of 16 as a 4-1 victory over Cameroon secured top spot in Group A.
Mexico also progressed from Group A as a glut of late goals saw them emerge with a 3-1 victory against Croatia.
El Tri finished level with Brazil on seven points but had to settle for second place as a result of the hosts' superior goal difference.
Mexico will face Netherlands in the next round after Louis van Gaal's men secured top spot in Group B with a 2-0 victory over Chile.
Spain ended their 2014 World Cup on a positive note with a 3-0 victory over Australia in Group B.
The Video has been deleted because of copyright violations
The defending champions had already known they would exit the competition at the group stage after losing to Netherlands and Chile but, playing for pride against the Socceroos, they secured their first points in Brazil.
[divider scroll_text=”Back To Top”]