The Moroccan Istiqlal (Independence) party, part of the current ruling coalition, elected deputy mayor of Fez Hamid Chabat as its leader on Sunday, an AFP journalist said.
Chabat, 53, won 478 votes, narrowly beat rival Abdelouahed El Fassi, a former health minister and son of a founder of the conservative movement, who secured 458 votes.
The AFP journalist present when the result was announced said it was not disputed.
"Today it is democracy that has won. We will work together with Abdelouahed El Fassi and turn over a new leaf. Our country is in need of real change, and today Istiqlal has set an example for other parties," Chabat told AFP.
Chabat becomes Istiqlal's fifth secretary general, succeeding former prime minister Abbas El Fassi, who was at the head of the government from 2007 to 2011 and in his party post since 1998.
The polling took place for the first time in the seaside town of Skhirat, near Rabat.
Istiqlal is the second most powerful party in the ruling coalition, after the moderate Islamist Justice and Development Party (PJD), which won an historic legislative election victory in late 2011 amid the upheaval of the Arab Spring.© ANP/AFP