Wales claimed the last automatic spot remaining in qualifying for next year’s European Championship by beating Hungary 2-0 in a winner-takes-all match in Cardiff on Tuesday.

Aaron Ramsey scored a goal in each half to propel the Welsh to a second straight Euros, after they reached the semifinals in 2016 in their first major tournament in 58 years.

Wales — coached by Manchester United great Ryan Giggs — climbed from fourth to a second-place finish in Group E behind Croatia, leaving Hungary to attempt to get to the finals via the playoffs in March. Slovakia, which beat Azerbaijan 2-0 on Tuesday, finished in third place and will also contest the playoffs.

Wales' Aaron Ramsey celebrates scoring his side's first goal of the game against Hungary during their UEFA Euro 2020 Qualifying soccer match at the Cardiff City Stadium, in Cardiff, Wales, Tuesday Nov. 19, 2019. (Nick PottsPA via AP)

Wales' Aaron Ramsey celebrates scoring his side's first goal of the game against Hungary during their UEFA Euro 2020 Qualifying soccer match at the Cardiff City Stadium, in Cardiff, Wales, Tuesday Nov. 19, 2019. (Nick PottsPA via AP)

The Welsh could be a threat at the Europe-wide tournament held in June and July next year, with their forward line containing Real Madrid’s Gareth Bale and Manchester United’s Daniel James while Ramsey — now at Juventus — makes runs from midfield.

Much will hinge on the fitness of the injury-prone Bale and Ramsey. This was the first time they started together for Wales in more than a year, and Bale set up Ramsey for the 15th-minute opener at the Cardiff City Stadium with a cross from the right that was headed home at the far post.

Ramsey’s second goal, in the 47th, was a cool finish from close range after he latched onto an acrobatic effort by substitute Kieffer Moore.

Aaron Ramsey, top right, of Wales scores the opening goal against Hungary, during the Euro 2020 group E qualifying soccer match between Wales and Hungary at Cardiff City Stadium in Cardiff, Wales, Tuesday, Nov. 19, 2019. (Tamas KovacsMTI via AP)

Aaron Ramsey, top right, of Wales scores the opening goal against Hungary, during the Euro 2020 group E qualifying soccer match between Wales and Hungary at Cardiff City Stadium in Cardiff, Wales, Tuesday, Nov. 19, 2019. (Tamas KovacsMTI via AP)

The Slovaks could have qualified in second place if the Wales-Hungary match had finished in a draw. They did all they could, winning in Trnava courtesy of Robert Bozenik’s 19th-minute goal and another from Marek Hamsik in the 86th.

On the final night of qualifying, top-ranked Belgium completed a perfect campaign in Group I by thrashing Cyprus 6-1 for a 10th straight win. Christian Benteke and Kevin De Bruyne both scored twice.

Germany and Netherlands were already assured of advancing from Group C and they both finished with big home wins. Serge Gnabry scored a hat trick in Germany’s 6-1 win over Northern Ireland and Georginio Wijnaldum also scored three goals in the Netherlands’ 5-0 victory over Estonia.

Germany topped the group, two points ahead of the Dutch.

More AP soccer: https://apnews.com/Soccer and https://twitter.com/AP_Sports

Steve Douglas is at www.twitter.com/sdouglas80