RABAT, Morocco — Moroccan King Mohammed VI has named Abdelilah Benkirane to a second term as prime minister after his Islamist Party of Justice and Development beat out a secular party close to the royal palace and 26 others to win legislative elections.

The palace said in a statement that the king met with Benkirane on Monday and asked him to create a government, according to the state news agency MAP. The PJD will have to form a coalition government because it didn’t win a majority in Friday’s elections.

The PJD has had a spotty economic record and its main rival accuses it of turning a blind eye to rising extremism. But it remains popular after rising to power following 2011 Arab Spring protests calling for less royal control over politics.