PORTO, Portugal (AP) - Cristiano Ronaldo scored a hat trick to move past Pele on the list of all-time international goalscorers as Portugal beat Faeroe Islands 5-1 on Thursday to stay close to Switzerland at the top of Group B in World Cup European qualifying.

Ronaldo netted with a neat volley from inside the area then added two other goals to lift his career tally to 78 and surpass the great Pele, who scored 77 for Brazil.

On the European list, Ronaldo is now six goals behind Hungary legend Ferenc Puskas.

Portugal's Cristiano Ronaldo, left, celebrates after scoring his side's second goal during the World Cup Group B qualifying soccer match between Portugal and Faroe Islands at the Bessa Stadium in Porto, Portugal, Thursday Aug. 31, 2017. (AP Photo/Paulo Duarte)

Switzerland stayed perfect in qualifying by defeating Andorra 3-0 in a match interrupted by poor pitch conditions under heavy rain in St. Gallen.

The Swiss lead the group with 21 points, three clear of Portugal, and are guaranteed to finish first or second. The winner automatically qualifies for the 2018 World Cup in Russia, while the runner-up has to go through a playoff.

"Things are going well for me with Portugal," Ronaldo said. "The team is playing well and we are still alive. We gained confidence after this victory and we will keep focused to make sure we can make it to the World Cup."

Hungary stayed a distant third with 10 points after defeating last-placed Latvia 3-1 at home.

___

RED-HOT RONALDO

Ronaldo scored twice in the first half and once after the break to reach 14 goals in seven Group B matches.

The Real Madrid striker opened the scoring with a side-volley by the far post.

"I had been trying to score a goal like this for a long time," Ronaldo said. "It was the goal that was missing in my career."

He added his second by converting a penalty kick, and the third came after a neat fake shot that fooled a defender and left him open in front of the goal.

William Carvalho and Nelson Oliveira also scored for the defending European champions, which have won six straight matches since their opening loss at Switzerland.

___

WET WIN

Switzerland overcame poor pitch conditions in St. Gallen to defeat Andorra for its seventh straight victory in Group B.

The match was interrupted in each half as workers came on the field to clear standing water.

Haris Seferovic scored just before halftime and again after the break, and Stephan Lichtsteiner added the final goal for the 3-0 victory.

___

HUNGARY HOPES

Hungary kept pace with Switzerland and Portugal thanks to a routine 3-1 win over last-placed Latvia.

Tamas Kadar and Adam Szalai scored for Hungary in the first half and Balazs Dzsudzsak added the third following the break after Gints Freimanis had pulled Latvia closer before halftime.

The victory left Hungary five points clear of fourth-placed Faeroe Islands.

___

More AP World Cup coverage: https://apnews.com/tag/WorldCup

Portugal's Cristiano Ronaldo celebrates after scoring the opening goal during the World Cup Group B qualifying soccer match between Portugal and Faroe Islands at the Bessa Stadium in Porto, Portugal, Thursday Aug. 31, 2017. (AP Photo/Paulo Duarte)

Portugal's Cristiano Ronaldo, center, controls the ball during the World Cup Group B qualifying soccer match between Portugal and Faroe Islands at the Bessa Stadium in Porto, Portugal, Thursday Aug. 31, 2017. (AP Photo/Paulo Duarte)

Portugal's Cristiano Ronaldo, top, jumps for the ball during the World Cup Group B qualifying soccer match between Portugal and Faroe Islands at the Bessa Stadium in Porto, Portugal, Thursday Aug. 31, 2017. (AP Photo/Paulo Duarte)

Andorra's Jordi Rubio, left, struggles against Swiss defender Ricardo Rodriguez during the 2018 World Cup group B qualification soccer match between Switzerland and Andorra at the kybunpark stadium in St. Gall, Switzerland, Thursday, Aug. 31, 2017. (Gian Ehrenzeller/Keystone via AP)

Swiss midfielder Granit Xhaka with Andorra's Ludovic Clemente, right, during the 2018 World Cup group B qualification soccer match between Switzerland and Andorra at the kybunpark stadium in St. Gall, Switzerland, Thursday, Aug. 31, 2017. (Gian Ehrenzeller/Keystone via AP)

Workers try to clear water from the pitch during the Andorra against Switzerland, during the 2018 World Cup group B qualification soccer match between Switzerland and Andorra at the kybunpark stadium in St. Gall, Switzerland, Thursday, Aug. 31, 2017. (Peter Schneider/Keystone via AP)

Andorra's Alex Martinez, left, in action with Swiss defender Stephan Lichtsteiner, during the 2018 World Cup group B qualification soccer match between Switzerland and Andorra at the kybunpark stadium in St. Gall, Switzerland, Thursday, Aug. 31, 2017. (Walter Bieri/Keystone via AP)

Adam Szalai, left, of Hungary fights for the ball with Kaspars Gorkss of Latvia during the 2018 FIFA World Cup qualification match between Hungary and Latvia in the Groupama Arena in Budapest, Hungary, Thursday, Aug. 31, 2017. (Tibor Illyes/MTI via AP)

Balazs Dzsudzsak, right, of Hungary fights for the ball with Kaspars Gorkss of Latvia during the 2018 FIFA World Cup qualification match between Hungary and Latvia in the Groupama Arena in Budapest, Hungary, Thursday, Aug. 31, 2017. (Tibor Illyes/MTI via AP)