The six days of intensive negotiations were concluded hours after Mauritania's former prime minister, Yahya Ould Ahmed Waghf, was freed from jail.
Waghf was detained in the wake of August's military coup, in which Abdallahi, Mauritania's first democratically elected president, was removed from power.
His removal was spearheaded by General Mohamed Ould Abdel Aziz, whose decision to give up power as president in April constitutionally allowed him to run in elections.
The Dakar talks were organised by an international group of mediators, including officials from the African Union, the European Union, the United Nations and the Arab League among others.
Abdoulaye Wade, the Senegalese president, who was closely involved in the negotiation process, presided over the signing of the agreement at the capital's convention centre.