A Kai Havertz double led Germany to a 4-2 victory over Costa Rica on Thursday, but Spain was knocked out of the World Cup by Japan.
Germany finished third, behind Spain and Japan, on goal difference, after Japan beat Spain. Japan and Croatia will meet in the last 16.
Despite dominating the game, Germany were unable to add to their lead over Costa Rica in the first 45 minutes.
- Ogden: Germany humiliated with second-straight group exit
- World Cup tiebreakers: What happens if team is level on points?
Hansi Flick's side needed to win to have any chance of avoiding a second-successive group stage elimination and suddenly found themselves behind after Costa Rica scored two goals in a row.
In the first half I was very angry with my team and how they allowed the opponent to come back. We wanted to score a lot of goals in the first half, but we made a lot of mistakes.
16 of them would have been converted if we had done that. The tournament wasn't decided for us. The reason we were eliminated was because we didn't have any efficiency.
With the group results on the big screen of the Al Bayt stadium, Germany became nervous with the sensational Jamal Musiala twice hitting the post.
13 minutes after the restart, Tejeda thundered the ball past Neuer on the rebound after he had first saved Waston's goal.
The ball went over the line in the 70th minute to give Costa Rica the lead.
Havertz came off the bench to score twice for Germany to put them back in the lead and Niclas Fullkrug added their fourth, but Spain's loss to Japan sealed their fate.
It was the first time in their illustrious World Cup history that Germany had failed to win any of their first two group matches, and despite bagging a win on their last attempt, they will be leaving with a bad taste in their mouths.
The first all-women crew to oversee a game at a men's World Cup match was made up of referees.