The leader of the National Rally of Independents party (RNI) in Morocco declared the results of the legislative elections a "victory of all Moroccans" after his party won the most seats.
With nearly all of the votes counted, the Interior Ministry said the RNI took 97 out of 395 seats in the lower house of parliament.
The Islamist Justice and Development Party (PJD), which has led the government since 2011, won only 12 seats, down from 125 in the last elections in 2016.
RNI leader Aziz Akhannouch lauded the results and said it was "a victory for democracy, its spirit and its rules."
His party has promised to create 1 million jobs to boost the economy after the pandemic, expand health insurance to all Moroccans, increase teacher salaries and provide a guaranteed pension for the elderly.
Under the country's constitution, the king appoints the prime minister from the party which wins most seats, who will then proceed to form a government.
Overall, the role of lawmakers is limited by the powers of King Mohamed VI, who oversees strategic decision-making in Morocco, an important ally of the West in efforts to fight extremism and stem migration from Africa to Europe.
It remains unclear if the PJD will be part of the upcoming governmental coalition, or move back into the opposition ranks for the first time in more than a decade.
RNI's likely coalition partner, the Authenticity and Modernity Party (PAM), came in second with 82 seats, while the Istiqlal (Independence) Party finished third, netting 78 seats.
Go to video
Breaking barriers: Women in Nigeria defy odds to contest in elections, but face uphill battle
Benin opposition wins 28 seats in early poll results
Benin's opposition parties will be on the ballot in Sunday's election
Tunisia's Saied downplays low turnout in parliamentary elections
Tunisia prepares for the legislative elections
Tunisia's union chief denounces legislative elections