Despite having a larger number of voters, the PJD appear to have secured less seats
Morocco's Islamists came first in regional elections seen as a test of their popularity after nearly four years in power, but trailed the liberal opposition in municipal polls, results showed on Saturday.
Friday's double elections were viewed as a gauge of the political climate ahead of a general election next year.
They come four years after Arab Spring protests ushered in constitutional reforms by the monarchy in the North African nation.
Prime Minister Abdelilah Benkirane's Justice and Development Party (PJD) won 25.6 percent of 678 seats in regional councils.
The Party of Authenticity and Modernity (PAM), a liberal opposition party founded by a politician close to the king, came second with 19.4 percent.
No sign of slowing electoral momentum for Morocco's moderate Islamist PJD as it performs well in municipal elections http://t.co/Tw94SPMbqH
— Borzou Daragahi (@borzou) September 6, 2015
It was the first opportunity for Moroccan voters to elect their regional councillors directly.
The PJD came first in five of Morocco's 12 regions, including in Casablanca, Rabat and Fez, cities with large populations.
However, the PJD's larger share of votes is not reflected in the party's number of seats due to the current electoral system, a Moroccan source told the website Arabi21.com.
The PJD received a total of around 1.5 million in both polls, giving it lead of half a million votes ahead of the PAM, but the party with the fewer votes secured more seats, the source added.
On Sunday, Morocco's main opposition parties refused to form a coalition with the ruling party.
In the municipal polls, the PAM came first with 21.1 percent of 31,503 seats, while the conservative opposition Istiqlal Party followed with 16.2 percent.
The PJD came third with 15.9 percent.
Earlier the interior ministry had said a tally of 80 percent of the overall votes indicated the PAM was leading.
The PJD hailed its stronger performance compared with the previous local elections in 2009, when it finished with 5.4 percent, far behind PAM which scored 21 percent.
"These results confirm the confidence of the Moroccan people in the work of the government," Abdelali Hamieddine, a senior official with the Islamist party, said of the earlier partial results.
The interior ministry said turnout was 53.6 percent, little changed compared with 2009. About 15 million people were eligible to vote.
In 2011, Benkirane's PJD became the country's first Islamist party to win a national election, and the first to lead a government.
That vote followed concessions from King Mohammed VI, the scion of a monarchy that has ruled Morocco for 350 years.
A new constitution curbed some, but not all, of the king's near-absolute powers as pro-democracy uprisings unseated autocratic regimes in Tunisia, Egypt and Libya.
The local polls were boycotted by Morocco's largest Islamist movement, Justice and Charity, and the smaller, far-leftist party Democratic Path.