DOHA, Qatar — Spain coach Luis Enrique said he had “nothing to celebrate” despite sealing qualification for the knockout rounds of the World Cup and admitted he would have had a “heart attack” had he realised that at one point they were heading out.

Spain were beaten 2-1 by Japan at Khalifa International Stadium on Thursday to finish second in Group E.

Stream on ESPN+: LaLiga, Bundesliga, more (U.S.)

But for three minutes in the second half, with Costa Rica leading Germany 2-1, they were facing an early exit and were only saved by Germany eventually winning 4-2.

“In football you deserve it or not and we didn’t deserve it,” Enrique told a news conference afterwards.

“I’m not happy at all. I would have liked to be on top and win but in five minutes Japan scored two. We were dismantled.

“We didn’t have any danger in the first half and then at half-time I told them to be cautious because they had nothing to lose. We collapsed and they could have scored two more goals. I’m not happy at all.

“I never celebrate defeats so we have nothing to celebrate. We have qualified but I have nothing to celebrate.”

Luis Enrique’s Spain were stunned by two goals in five minutes from Japan at the start of the second half. JAVIER SORIANO/AFP via Getty Images

Enrique claimed in his post-match news conference that he was never aware that Spain were on the verge of being knocked out and said he was glad that news from the other game did not filter through.

“We were knocked out for three minutes?” replied Enrique when he was told how close Spain had come to being eliminated.

“I was not paying attention to the other match, when did that happen? I didn’t know this. I’m not happy because we were defeated by Japan. If I had found out [Spain were going out] I would have had a heart attack.”

Meanwhile, Japan finished top of Group E ahead of both Spain and Germany to set up a last-16 clash with Croatia.

– Johnson: Why Japan’s winning goal was awarded by the VAR– Dawson: Japan stage dramatic rally to reach round of 16

They battled back from a goal down against Spain, although there was controversy surrounding Ao Tanaka‘s winner after the ball was initially judged to have rolled out of play in the build up before the decision was overturned by VAR.

The goal ended up costing Germany a place in the knockout rounds and Tanaka admitted that it was a close call.

“From my angle the ball was clearly half out,” he said.

“More than that I could not say because of the speed. I was concerned about scoring but there was always a possibility that it was going to be out.

“If it was not out and it was not a goal I would not have been disappointed but in the end it was a goal so that was great.”