The Islamist party which has headed Morocco's coalition government since Arab Spring-inspired protests five years ago has beaten liberal rivals in parliamentary elections, results showed Saturday.
Prime Minister Abdelilah Benkirane's Islamist Justice and Development Party (PJD) took 125 seats out of 395, the interior ministry said after all ballots were counted.
Its main rival, the Authenticity and Modernity Party (PAM), which had campaigned against the "Islamisation" of Moroccan society, won 102 seats, the ministry said.
Istiqlal, the party which historically fought for independence from France, came third with 45 seats.
In any case, the real power will remain in the hands of King Mohammed VI, the scion of a monarchy that has ruled the North African country for 350 years.
Interior Minister Mohamed Hassad said that the election was "transparent" and had gone well, rejecting accusations of voter fraud from both sides.
The PJD had earlier issued a statement saying it was "very concerned about numerous reports of fraud being carried out by authorities" in favour of the PAM, and called on the interior ministry to "urgently intervene".
PAM spokesman Khalid Adennoun declined to comment but said that his party had filed "50 complaints" of voting irregularities, some concerning the PJD in Tangiers.
An Islamist candidate was attacked and wounded outside a polling station in Rabat, according to local media.
A video shared on social networks also showed a man stuffing a ballot box, leading the PJD to file a complaint, media reported.
Participation was at 43 percent, or roughly 6,750,000 voters, Hassad told a press conference in the capital Rabat.
Early turnout had been low in Rabat with many people waiting until after the weekly noon prayers to cast their ballots while others trickled to the polls after office hours.
Meriem, a voter in her 40s, said after casting her ballot in central Rabat: "I came to carry out my duty as a citizen. Our Morocco needs a healthy democracy."
To make life easier for the illiterate, who make up a third of Morocco's population, the 30 parties in contention were marked on ballot papers with symbols such as a tractor or camel.
The PJD came to power in 2011, months after massive street protests prompted concessions from the monarchy.
A new constitution transferred some of the king's powers to parliament, at a time when autocratic regimes were falling in Tunisia, Egypt and Libya.
While in government, the PJD passed a controversial reform of the retirement system and followed a relatively liberal economic policy.
Its task has been complicated by the unstable world economy and a drought this year that hit Morocco's vital agricultural sector and sent growth plummeting.
The party has been weakened by rising unemployment and what critics say is a failure to make good on promises in 2011 to tackle corruption.
It has also faced a string of scandals within its ranks including a drugs bust, a land-grab deal and the suspension of two vice presidents found in a "sexual position" on a beach.
The opposition PAM, formed in 2008 by a close adviser to the king, had hoped to take advantage in the polls.
Headed by Ilyas El Omari, it has poured enormous resources into a campaign criticising the government's economic record as "catastrophic" and pledging to roll back the "Islamisation" of society.
Several parties fielded ultra-conservative Salafists, in a sign that Islamists are becoming a feature of Moroccan politics.
The PJD and the PAM have ruled out joining forces in a grand coalition.
Under the 2011 constitution, the king appoints a prime minister from the biggest party in parliament once the election results have been announced.