Morocco's moderate Islamist Justice and Development Party (PJD) has won the most seats in Friday's parliamentary elections, final results confirm.
The interior ministry said the PJD took 107 out of 395 seats, giving it the right to lead a government.
Its likely coalition partner, the nationalist Istiqlal party, came second, with 60 seats.
The poll is part of reforms which King Mohamed VI hopes will defuse protests prompted by the Arab Spring.
"This is a clear victory, but we will need alliances in order to work together," PJD secretary-general Abdelilah Benkirane told the AFP news agency after the official results were announced.
Under a new constitution adopted in July, King Mohamed must now appoint the prime minister from the party which wins the most seats, rather than naming whomever he pleases.
But the king still has the final say on issues of defence, security and religion.
'Victory for democracy'
Morocco's current Prime Minister, Abbas Al Fassi, said on Saturday his Istiqlal party was ready to enter into a coalition with the PJD.
"The PJD's victory is a victory for democracy," he told Reuters.
It comes a month after the moderate Islamist Ennahda party won elections in nearby Tunisia.
The PJD has said it will promote Islamic finance. However, it has avoided focusing on issues such as alcohol and headscarves for women, in a country which attracts large numbers of Western tourists.
Historian and political analyst Maati Monjib told the Associated Press that Moroccans linked Islam and political dignity.
"There is a big problem of dignity in the Arab world and the people see the Islamists as a way of getting out of the sense of subjugation and inferiority towards the West."
The Interior Ministry said 45.4% of the electorate had turned out to vote.
About 13.5 million Moroccans are eligible to vote. Although the turnout was an improvement on the 37% who took part in the 2007 election, it was less than the 51.6% in 2002.
The pro-reform February 20 movement, responsible for the protests staged just before the king announced his plans to reform the constitution, had called for a boycott of the vote.
"This [low turnout] sends a strong signal to authorities that Moroccans are not buying the proposed reforms," Najib Chawki, an activist with the movement, told Reuters.
"We will not give up until our demands are met," he added.