section_path: Companionship of Muhammad/Political career
section_name: Political career
paragraph_text: Political career
  
  In Medina, Ali acted as Muhammad's secretary and deputy. He was also one of the scribes tasked with committing the Quran to writing. In 628, Ali wrote down the terms of the Treaty of al-Hudaybiya, the peace treaty between Muslims and Meccan pagans. In 630, divine orders pushed Muhammad to replace Abu Bakr with Ali for a key Quranic announcement in Mecca, according to the canonical Sunni source Sunan al-Nasa'i. Ali also helped ensure that the Conquest of Mecca in 630 was bloodless and later destroyed the idols housed in Ka'ba. In 631, Ali was sent to preach Islam in Yemen, as a consequence of which the Hamdanids peacefully converted. Ali also peacefully resolved a blood feud between Muslims and the Banu Jadhima.