RABAT Morocco's moderate Islamists have won parliamentary elections, beating a rival party critics say is too close to the royal palace in a tight race that will complicate negotiations to form a coalition government.
The government has only limited powers, but Friday's ballot for the House of Representatives was a test for the constitutional monarchy five years after Mohammed VI devolved some authority to ease protests for democratic change.
After five years in government, the Justice and Development Party (PJD) won 125 seats while the Authenticity and Modernity Party (PAM) party took 102, according to final results announced by the interior minister on Saturday.
The conservative Istiqlal party took 46 seats.
Under Morocco's system no party can win an outright majority in the 395-seat parliament and the winner must form a coalition government.
The king, who retains most executive power, chooses a premier from the winning party, but building a coalition promises to be tough for the PJD.
With its main rival PAM scoring high and ruling out an alliance, the Islamists potentially need to partner with at least three other parties to secure a majority.
Since being appointed prime minister in 2011, PJD leader Abdelilah Benkirane has pursued economic reforms to reduce the budget deficit and tackle subsidies. The PJD has been popular for its anti-corruption message.
"The PJD has proven today that being serious and truthful ... and being faithful to the institutions, especially the monarchy, is a winning currency," Benkirane told reporters.
PAM, founded by a close friend of the king who is now a palace adviser, had presented itself as a liberal alternative to Islamists. Critics say it was used by the royal establishment, always uncomfortable with sharing power with Islamists, to roll back PJD influence.
"We were expecting more seats but ... our modernist project has done well despite all attacks," Khalid Adnoun, PAM spokesman said. "There will be no alliance with PJD. If they get their coalition, we will be in the opposition".
During its early years in office, the PJD was in coalition with Istiqlal, but the conservative partner dropped out in 2013, it said, to protest over economic reforms that hit Moroccan spending power.
That makes another PJD alliance with Istiqlal tricky.
A fourth party, the centre-right National Rally of Independence or RNI - part of the outgoing coalition and which won 37 seats in Friday's ballot - has also ruled out another partnership with the Islamists.
Other smaller parties are highly fragmented and only secured a few seats.
When protests erupted in 2011, the king called a referendum on a constitutional reform ceding some powers to the elected government and guaranteeing more rights. He also increased social spending and used security forces to curb protests.
Since then, Moroccan leaders have presented the kingdom as a model for economic stability and gradual change and a welcome target for foreign investment in a region where violence and political upheaval have become the norm.
The PJD is one of the only remaining Islamist parties leading a government after such parties took power following the Arab Spring revolts that toppled long-standing leaders in Libya, Egypt and Tunisia.
But Morocco's main Islamist opposition group, Justice and Spirituality, and left-wing organisations, which led protests for change in 2011, have boycotted elections in protest over the king's tight grip on power.
Campaigning for Friday's vote was tarnished by accusations that the royal establishment was unfairly backing PAM though the interior ministry organisation of the poll. Palace officials denied any favouritism.
Hours before polls closed on Friday, the PJD accused local officials under the control of the interior ministry of trying to influence voters at the polls. The ministry has dismissed some claims but said it would investigate others.
(Editing by John Stonestreet)