As Islam expanded throughout Arabia, Ali worked to build the new Islamic government. In 628, he was given the task of writing down the Hudaybiyyah agreement, a peace treaty between the Prophet and the Quraysh.