The town is the cradle of Mali's separatist movement, which wants independence for a vast swathe of northern desert it calls "Azawad" and which has launched several rebellions since the 1960s.
"We have just signed an agreement which opens the way for a ceasefire," Mauritanian President and African Union chairman Mohamed Ould Abdel Aziz said on Mali public television after brokering the deal.
"The deal comes into effect with the signature of all parties," he said, after first the rebel group in Kidal agreed and later Interior Minister Sada Samake signed on behalf of the government in Bamako.
He travelled by private jet and then helicopter to Kidal, 1,500 kilometres (900 miles) northeast of Bamako, accompanied by Bert Koenders, the head of the local UN mission MINUSMA.
Malian President Ibrahim Boubacar Keita praised the work of his Mauritanian counterpart in securing the deal.
"All day he negotiated. He convinced our brothers... That there is no alternative to peace and the negotiating table," he said.
The rebels said they had seized control of several places, a claim contested by the government, which had announced a unilateral ceasefire on Wednesday.
The army has been pinned back by a coalition of several armed groups, including Tuareg separatists.
Bamako and the rebel group agreed to release prisoners as soon as possible, to facilitate UN humanitarian efforts "and to respect the principles of human rights," MINUSMA said.
