As a prominent Muslim in Yunnan, Ma became involved in the Panthay Rebellion in Yunnan shortly after he returned from the Hajj. The Panthay Rebellion, which flared up in 1856 as part of a wider series of uprisings by Muslims and other minorities, was led mainly by Du Wenxiu; though Ma disagreed with Du Wenxiu's revolutionary methods, he also encouraged his followers to aid in the uprising; later, he would try to act as a peacemaker between the central government forces and the rebels. However, despite his efforts to bring about peace, the Qing government still regarded him as a rebel and a traitor; he was executed two years after the suppression of the rebellion.Europeans reported that he was either poisoned or executed.
Sources say that Ma produced the first Chinese translation of the Qur'an, as well as writing numerous books in Arabic and Persian about Islam. His most famous writings compared Islamic culture and the Confucian philosophy in an effort to find a theoretical and theological basis for their coexistence. At the same time, he harshly criticised the absorption of Buddhist and Taoist elements into the practise of Islam in China. As he is generally regarded as an orthodox Islamic thinker, his writings also demonstrated a positive attitude towards Tasawwuf, or Sufi mysticism. In total, he published over 30 books, most of which fall into five categories.