Croatia crushed England's World Cup hopes in July. By beating Spain in a thriller on Thursday, the Croats have given Gareth Southgate's squad a chance to advance to the final phase of the inaugural UEFA Nations League.

Tin Jedvaj scored his second goal three minutes into stoppage time to earn Croatia a 3-2 victory and a first win in a competitive match since beating England in the World Cup semifinals.

Spain remained atop League A, Group 4 with six points. England and Croatia have four points each ahead of their head-to-head meeting at Wembley Stadium on Sunday in the last match.

A win for either England or Croatia will assure qualifying for the Final Four in June along with the other three group winners. Spain would go through if England and Croatia draw. The bottom team will be relegated to League B.

"We wanted to win this and to have the last match at Wembley to decide the group winner," Croatia coach Zlatko Dalic said. "Let's go and enjoy our football now. We are very motivated for that one."

While Croatia beat former world champion Spain, England eased to a 3-0 win over the United States in a friendly marking the farewell appearance of Wayne Rooney.

Elsewhere in the Nations League, Belgium beat Iceland 2-0 to stay on course to reach the finals. In the lower leagues, Bosnia and Herzegovina earned promotion to League A, and Finland earned promotion to League B.

Croatia's win avenged a 6-0 loss, its worst ever, to Spain in September.

The World Cup finalists pressed Spain in its area late and Jedvaj pounced after goalkeeper David de Gea pushed the ball into his path. The Bayer Leverkusen defender had earlier made it 2-1 to the hosts when he was left unmarked to head in a cross by Luka Modric for his first international goal.

Spain twice rallied to equalize, first through Dani Ceballos canceling out Andrej Kramaric's opener and then via a penalty by Sergio Ramos.

Luis Enrique's lineup was pressing for a late goal when Croatia produced one last push that paid off with Jedvaj's second score.

"Croatia got that little bit of fortune when both teams were desperately trying to win this match right at the end," Luis Enrique said.

Making his 120th and last appearance for England, the 33-year-old Rooney was denied a perfect farewell by Brad Guzan when the U.S. goalkeeper dived to stop his shot in stoppage time.

Recalled after two years out of the England squad, the D.C. United forward sparked the biggest cheers of the night when he went on as a 58th-minute substitute against the country he now calls home.

Michy Batshuayi, replacing the injured Romelu Lukaku in attack, scored twice as Belgium beat Iceland for a third victory in the Nations League.

A draw against Switzerland on Sunday would be enough for Belgium to reach the finals. It has nine points from three games in Group 2 of League A, three ahead of Switzerland. Iceland had already been relegated to League B before the match.

France and Portugal are also favored to reach the finals from their groups in League A.

Bosnia and Herzegovina will join the top 12 teams on the continent for the next Nations League after it won Group 3 of League B. The Balkan nation got the point it needed by drawing 0-0 at Austria and remaining undefeated. The result also relegated Northern Ireland.

Finland won Group 2 of League C with one match remaining despite losing 1-0 against Greece. Estonia was relegated from the same group after losing 2-0 at Hungary.

In League D, already-promoted Georgia drew 1-1 at Andorra, Latvia drew 1-1 at Kazakhstan, Belarus won 2-0 at Luxembourg and Moldova won 1-0 at San Marino.

More AP soccer: https://apnews.com/tag/apf-Soccer and https://twitter.com/AP-Sports