Portugal had already secured the top spot in Group A1, while Croatia managed to finish one point ahead of Scotland, who continued their late surge with a 2-1 victory over Poland in Warsaw.
In Group A4, Spain, already assured of qualification, beat last-placed Switzerland 3-2 in a match of penalty kicks in Tenerife.
Denmark secured second place in the group with a 0-0 draw in Serbia.
In Split, Portugal took a 33rd-minute lead when Joao Felix neatly finished a sharp counterattack. Rafael Leao then missed the target when clean through.
With Scotland winning in Warsaw after a third-minute goal from John McGinn, set up by teenager Ben Doak, Croatia were heading out.
Gvardiol, ghosting at the far post, had a header on 62 minutes disallowed for offside. He repeated the move three minutes later, sneaking in unmarked and onside to squeeze a close-range shot through Jose Sa. Gvardiol, a defender, has three goals in his last six Premier League games for Manchester City.
"It felt like two different games for us," said Gvardiol. "In the first half, we seemed a bit tired and needed to make changes. The second half was much better -- we had more energy, better control of the ball, and created more chances and we managed to score a goal."
Almost simultaneously in Warsaw, Kamil Piatkowski rocketed a cross shot into the top far corner of the Scottish goal to level for Poland.
In the 73rd minute in Split, left-back Nuno Mendes nearly emulated Gvardiol for Portugal but goalie Dominik Livakovic blocked.
In Warsaw, Andy Robertson headed home in added time to give Scotland a second win in four days, but Croatia comfortably saw out the draw they needed.
"I told the boys they earned this result through their hard work, though it seems we always have to struggle for it," said Croatia coach Zlatko Dalic.
"While there might have been a results crisis, there was never a crisis in our play."
Scotland go into a play-off to save their League A status. Poland are relegated.
Scotland coach Steve Clarke said he was happy with his country's improvement.
"We started with three defeats, three narrow defeats, with good performances. The players didn't lose belief, I didn't lose belief in the players and they end up taking seven points from the last three games which gets us into the play-off," he said.
I can't ask for moreIn Tenerife, Alvaro Morata's clever turn won a penalty just after the half-hour. Yvon Mvogo saved Pedri's low, hard spot kick but, after some pinball, Yeremi Pino, from the neighbouring Canary island of Las Palmas, scored.
Joel Monteiro dribbled through the Spanish defence for a spectacular 63rd-minute equaliser.
Bryan Gil stole the ball in the Swiss area to put Spain ahead again five minutes later.
Andi Zeqiri levelled again, with a penalty five minutes from time.
Deep into extra time, Bryan Zaragoza converted Spain's second spot kick.
For both the Bryans it was a first international goal.
"Here at home with a goal, the win," said Pino. "I can't ask for more."
In Leskovac in Serbia, the hosts needed to win to overtake visiting Denmark and reach the quarter-finals.
On a night when both goalkeepers, Dorde Petrovic and Kasper Schmeichel, were in eye-catching form, the hosts had to settle for a 0-0 draw.
ALSO READ | BGT 2024-25: Ravi Shastri wants India batters to 'think about' last Australia tour's performance in Perth
The goalkeeping was less spectacular in Luxembourg in League C, where Northern Ireland blew a two-goal lead in Luxembourg to draw 2-2 but topped Group 3 when Bulgaria threw away a lead and drew 1-1 in Sofia against Belarus.
In Group 2, Romania beat Cyprus 4-1 in Bucharest to stay top of the group, two points ahead of Kosovo, who beat Lithuania 1-0 in Pristina despite playing the second half with 10 men.
In League D, San Marino came from a goal down to beat Liechtenstein 3-1 in Vaduz and edge Gibraltar to first place in Group 1.
Disclaimer: This story has been published from a news agency feed with minimal edits to adhere to web's style guide. The headline may have been changed to better reflect the content of the story or to make it more suitable for web audience.