BORDEAUX, France — Spain’s 12-year unbeaten run at the European Championship ended Tuesday when Croatia came from behind to stun the two-time champion.

The 2-1 defeat relegated Spain to second place in Group D and set up a mouthwatering Round of 16 game between Spain and Italy, a repeat of the final four years ago. Ivan Perisic’s 87th-minute winner also ended Spain’s unbeaten run at the tournament that stretched back to 2004.

A draw would have been enough for Spain to secure first place in the group and a potentially easier second-round game.

Now it will have to face the Italians on Monday in Paris – a repeat of the 2012 final that Spain won, 4-0. Croatia will play one of the third-place teams in the northern French city of Lens on Saturday.

“It’s not the best path for us, but you never know where the danger will be,” Spain Coach Vicente Del Bosque said. “We wanted to advance in first place but we are prepared to overcome this.”

TURKEY 2, CZECH REPUBLIC 0: Turkey rebounded from two losses to win at Lens, France, and keep alive its chances of reaching the knockout stages from Group D.

With their team having failed to score in its defeats to Spain and Croatia, the Turkish fans celebrated with firecrackers and flares that landed on the pitch after the second goal.

Turkey must wait until the final group matches are played Wednesday to discover whether it can advance as one of the four best third-place teams.

Spain has six points, Turkey has three and the Czechs are eliminated with one point, 20 years after their team reached the final and 40 years after becoming European champions as Czechoslovakia.

GERMANY 1, NORTHERN IRELAND 0: Germany missed a series of clear chances at Paris, still the victory ensured the 2014 World Cup winner topped Group C and advanced to the knockout stages.

Northern Ireland need not care it lost. Three hours later, its place in the Round of 16 was confirmed by Turkey’s 2-0 victory against the Czech Republic in Group D.

That ensured Northern Ireland – watched in the stands by former No. 1 golfer Rory McIlroy – will be among the four best third-placed teams to advance.

POLAND 1, UKRAINE 0: Poland won at Marseille, France, and made it into the knockout round for the first time, beating Class C opponent Ukraine, which already had been eliminated.

Second-half substitute Jakub Blaszczykowski struck the winner in the 54th minute. Poland qualified second from the group behind Germany, both with seven points.

Blaszczykowski scored from a cleverly worked short corner kick.