AL RAYYAN, Qatar — Most teams at this World Cup have talked about being family.
The Moroccan team has truly been one.
The country's soccer federation, acting on the request of coach Walid Regragui, has paid to bring players' relatives to Qatar for the tournament and the team has paid it back by becoming the first African country to reach the quarterfinals since Ghana in 2010.
Morocco's victory over Spain on penalty kicks Tuesday was just the latest — and most dramatic — surprise of a World Cup that has been full of twists and turns. Argentina, which came to Qatar ranked third in the world and unbeaten in 36 straight games, lost its opener to No. 51 Saudi Arabia. Argentina went into that match with almost as many World Cup titles, two, as Saudi Arabia had World Cup wins, three.
Lionel Messi and Co. recovered to win their next three games and advance to the quarterfinals, where they will meet the Netherlands on Friday.
Top-ranked Brazil, meanwhile, lost Neymar to an ankle injury in its opener, then stumbled through its next two matches. But Neymar's return in the round of 16 brought back Brazil's flair and panache, resulting in a dominant 4-1 win over South Korea that reestablished the team as the tournament favorite. It will play Croatia, the 2018 runner-up, in its quarterfinal while France, the reigning champion, will meet England on Saturday.
Belgium, Germany, Uruguay, Denmark and Mexico, all ranked in the top 14, never did find their stride in Qatar, with all five teams going out in the group stage. Denmark didn't even win a game.
Morocco, however, is still standing. It will meet Portugal on Saturday with a chance to become the first African team to reach the World Cup semifinals, and the $17 million in bonuses it earned by making it this far has already paid for the investment the federation made to create the family environment around the team.
For Regragui, 47, a former national team defender who played for 13 years in France and Spain, the program has proved personally fulfilling as well.
"During his whole career as a player and as a coach, I never traveled to watch him," his mother Fatima told Moroccan sports channel Arryadia. "I've been living in France for more than 50 years now and this is the first competition that I left Paris for."
But it's also part of a bigger plan to cleanse the toxic environment created by Vahid Halilhodzic, Regragui's predecessor, who was fired three months before the World Cup. Halilhodzic, who was previously sacked by Japan and Ivory Coast between qualifying for a World Cup and the start of the tournament, was criticized for leaving foreign-born defenders Hakim Ziyech and Noussair Mazraoui off his roster for last winter's Africa Cup of Nations, where Morocco was ousted in the quarterfinals.
Regragui welcomed both players back and Ziyech, who was born to Moroccan parents in the Netherlands, rewarded him by delivering one of the three successful penalty kicks that eliminated Spain and sent Morocco on to the final eight. The victory also touched off riotous celebrations in Morocco and Moroccan enclaves across Europe.
Even in Barcelona, Spain's second-largest city and home to nine players from the vanquished national team, people poured into the streets waving flags, honking horns and setting off flares. Morocco's king, Mohammed VI, said the players, 14 of whom were born outside Morocco, represent the "hopes and dreams of Moroccans … all over the world."
And much of the credit for that is going to the Parisian-born Regragui, who briefly served as an assistant coach with the national team a decade ago before going on to manage clubs in Morocco and Qatar, winning three league titles. He was managing Wydad AC in the domestic Botola when he was offered the national team job; many considered it a leap too far.
But Morocco is unbeaten under Regragui and in the World Cup its bunker-down style has proved effective. Although Morocco has ceded possession by wide margins in all four of its games, the only goal it conceded was scored by one of its own players.
Playing that way requires selflessness rare on a World Cup roster but Morocco has rallied around its coach, who started eight foreign-born players against Spain. And the coach showed he had his players' backs, too, allowing them to share their time on soccer's biggest stage with their families.
Which is how Achraf Hakimi, whose penalty kick sealed the win over Spain, was able to celebrate the victory with his mother, who was sitting behind the goal waving a Moroccan flag.
Hakimi, who was born in Madrid and learned to play soccer at Real Madrid's academy, also celebrated his team's group-stage win over Belgium with his mom, posting a photo of their postgame embrace on Instagram under the caption "I love you Mom."
Having family members in Qatar has made the team's headquarters at the Wyndham Doha West Bay feel like home. So has the presence of the approximately 15,000 Moroccans who live in Qatar, many of whom helped fill Education City Stadium on Tuesday, creating a deafening roar.
"It's impossible to do that without your fans," Regragui said of his team's success.
In the quarterfinals Morocco, ranked 22nd in the world by FIFA, the worst of any team remaining in the tournament, will see its familiar camaraderie tested by a Portuguese team that appears to be rife with strife. Cristiano Ronaldo, the team's star striker, was held out of the starting lineup for Tuesday's 6-1 win over Switzerland in the round of 16 after coach Fernando Santos expressed unhappiness with Ronaldo's attitude.
The benching didn't slow Portugal since Goncalo Ramos, Ronaldo's replacement, scored three times to become the first player in two decades to get a hat trick in his first World Cup start. Ramos also had an assist and after the win he joined his teammates in celebrating with their fans.
Ronaldo, who played the final 17 minutes off the bench, walked off the field alone.