By Saliou Samb

CONAKRY (Reuters) - Political rivals in the West African state of Guinea-Bissau have agreed that Prime Minister Baciro Dja can stay on until 2018, mediators said on Friday, a step forward in talks to end more than a year of infighting.

President Jose Mario Vaz sacked the previous prime minister in August 2015 and political institutions have been paralyzed ever since in the coup-prone country, a major transit point for cocaine trafficking between South America and Europe.

It was hoped the appointment of Dja as prime minister in May would ease the deadlock, but he has failed to win the support of a key faction within the ruling PAIGC party. The rival parties last month agreed to a road map that includes the formation of a new government.

Alpha Conde, president of neighboring Guinea, is leading the mediation effort.

"The prime minister should stay in place until legislative elections in 2018," said mediator Kiridi Bangoura, Guinea's general secretary of the presidency. "The formation of a government will be negotiated in a consensual manner with all the parties," he added.

The former Portuguese colony is highly unstable and has seen nine coups or attempted coups since 1980. U.N. officials fear the crisis, if left unresolved, might benefit drug traffickers and attract Islamist militants seeking to expand territory in the region.

(Writing by Tim Cocks; Editing by Mark Trevelyan)