Aqa Ali Shah was born in 1830 at Mahallat in Iran. He was the eldest son of Aga Khan I and the only surviving male issue of his father with Sarv-i Jahan Khanum (Sarv-i Jahān Khānum, d. 1882). Aqa Ali Shah was a member of the Iranian royal family, as his mother was the daughter of Fat′h Ali Shah, the second ruler of the Qajar dynasty. His rank as a prince of the royal family was also recognized by Nasser al-Din Shah Qajar when Aqa Ali Shah's father died. Nasser al-Din himself carried out a ceremony performed among Persian princes to mark the end of mourning of deceased relations. In addition, Nasser al-Din sent a robe of honour and the emblem of the Persian Crown studded with diamonds to Aga Ali Shah as a sign of the Shah's relationship with the Aga Khan's family.
He descended from the Fatimid caliphs of Egypt. He spent his early years in Mahallat; however, his father’s attempts to regain his former position as governor of Kirman made residence there difficult, and so Aqa Ali Shah was taken to Iraq with his mother in 1840. There he studied Arabic, Persian, and Nizari Ismaili doctrine, and soon gained a reputation as an authority on Persian and Arabic literature, as a student of metaphysics, and as an exponent of religious philosophy. In the late 1840s, changed political circumstances allowed Aqa Ali Shah to return to Persia where he took over some of his father's responsibilities. In 1853, Sarv-i Jahan Khanum and Aqa Ali Shah joined Aga Khan I in Bombay. As his father's heir apparent to the Ismaili Imamat, Aqa Ali Shah frequently visited various Ismaili communities in South Asia, particularly those in Sind and Kathiawar.
Aqa Ali Shah became Imam of the Ismailis upon the death of his father in 1881, also inheriting his father's title of Aga Khan. Aga Khan II maintained the cordial ties that his father had developed with the British and was appointed to the Bombay Legislative Council when Sir James Fergusson was the governor of Bombay. This was a noteworthy achievement, given that "nomination to the Council in those days was a rare distinction bestowed only on men of outstanding ability and high social position."
Imam Aqa Ali Shah also inherited his father's concern for his followers and was well-acquainted with their needs, having been assigned by his father to the duty of visiting the various communities in South Asia. For example, when confusion had arisen due to the fact that some of this followers in India were governed partly by Muslim law and partly by Hindu law, he was appointed a member of a commission in 1874 which was constituted to submit proposals for amendment of the law relating to his community.
Being concerned about the welfare of his followers, he also opened a number of schools for them in Bombay and elsewhere, and provided financial assistance to families in need. Although his imamate lasted only some four years, he was able to increase contacts with his followers living outside of the Asian subcontinent, particularly those who resided in the regions of the upper Oxus, Burma, and East Africa. He received much recognition for his work as he "discharged his responsible and onerous duties in a manner which drew the admiration and approbation of the community."
Imam Aqa Ali Shah was held in high esteem by the Indian Muslim population, a result of the improvement in the conditions of his own community, his policies, and his social activism. He was elected president of the Muhammadan National Association, a position that he held until his death. In his capacity as president, he was also involved in the promotion and organisation of educational and philanthropic institutions which served to improve the lives of members of the greater community of Muslims in India.
Like his father before him, Imam Aqa Ali Shah maintained close ties with the Nimatullahi Sufi order. This relationship was no doubt facilitated by the common Alid heritage that Aqa Ali Shah and the Nimatullahis shared: both Shah Nimatullah Wali (d. 1430-1), the eponymous founder of the order, and Aqa Ali Shah traced their ancestry to the Shia Imam Ja'far al-Sadiq and, hence, to Ali. It appears that the affiliation between the Nimatullahis and the Nizari Imams can be traced at least as far back as the 18th century to the 40th Nizari Imam, Shah Nizar, who had close connections with the order. Prior to going to India, Aqa Ali Shah had developed close relations with the leader of one of the Nimatullahi branches, Rahmat Ali Shah, who had been a guest of Aga Khan I in Mahallat in 1833. After Rahmat Ali Shah's death in 1861, Aqa Ali Shah often sent money from India for the recitation of the Qur'an at his grave in Shiraz. Aqa Ali Shah also had close ties with Rahmat Ali Shah's uncle as well as one of Rahmat Ali Shah's successors, Munawwar ‘Alī Shāh (d. 1884). Aqa Ali Shah received a number of important visitors belonging to the Nimatullahi order, including Rahmat Ali Shah's son Muḥammad Ma‘Ṣūm Shīrāzī, who visited India in 1881 and stayed with Aqa Ali Shah for a year. Another prominent figure of the Nimatullahi order received by Aqa Ali Shah was Safi Ali Shah, who first went to India in 1863 at Aqa Ali Shah's invitation.
Not much is known about Aqa Ali Shah's first two wives, both of whom died in Bombay. His first marriage with Maryam Sultana had two sons. The eldest, Shihab al-Din Shah (also known as Aqa Khalil Allah) was born around 1851-2 and wrote some treatises in Persian on Muslim ethics and Ismaili spirituality. He died in December 1884 of a chest complaint while still in his early thirties, and was buried in Najaf. The second son, Nur al-Din Shah, who was the full-brother of Shihab al-Din Shah, died around 1884-5 in a riding accident at Pune while still in his youth. It was said that, having lost two of his sons, Aqa Ali Shah died of a broken heart. After the death of his first wife, Aqa Ali Shah married a second time, but lost his second wife as well.
In 1867, Aqa Ali Shah took as his third wife Shams al-Muluk, the daughter of Khurshid Kulah Khanum (one of the daughters of Fat′h Ali Shah Qajar by Taj al-Dawla) and Mirza Ali Muhammad Nizam al-Dawla (a nobleman of great influence in the Persian court), the grandson of Muhammad Hussain Khan Ispahani, the Prime Minister of Shah Fateh Ali Qajar (d.1834) of Iran. Shams al-Muluk was also the niece of Muhammad Ali Shah of the Qajar dynasty. She has been described as "a well-rounded woman with soft good looks and luminous dark eyes hidden behind her yashmak" and a woman who "proved herself to be a most remarkable lady of rare attainments and great organizing power, and was well-known throughout the Muslim world". From his marriage with Shams al-Muluk, who came to be known as Lady Ali Shah (d. 1938), Aga Khan II had three sons, two of whom died in their infancy. His only surviving son and successor was Sultan Muhammad Shah.
Aqa Ali Shah's father began the family tradition of racing and breeding horses in Bombay. The first Aga Khan owned some of the world's finest Arabian horses, which were inherited by Aqa Ali Shah. Sultan Muhammad Shah later noted that when his father died, "he left a large and imposing sporting establishment in being — hawks, hounds, and between eighty and ninety racehorses".
Aqa Ali Shah was not only a skilful rider, but also an avid sportsman and hunter, and was particularly famous for his hunting of tigers in India. He was known to have pursued tigers on foot and to have had such a deadly shot that he killed at least forty tigers in this manner.
On one particular day of water-fowling near Pune in 1885, Aqa Ali Shah contracted pneumonia. Describing the incident, his son Sultan Muhammad Shah later wrote, "There were several hours' heavy rain, the going underfoot was heavy and wet, and my father was soaked to the skin. He caught a severe chill which turned swiftly and fatally to pneumonia." He died eight days later, after an imamate of four years, and was buried in the family mausoleum in Najaf on the west bank of the Euphrates, near Kufa and the tomb of Imam Ali, one of the holiest places in the world for Shia Muslims. The mausoleum is also the resting place of Aqa Ali Shah's grandfather, Shah Khalil Allah, who was the forty-fifth Imam of the Nizari Ismailis, and for whom the mausoleum was first constructed.
The untimely loss of his father, Aqa Ali Shah, so soon after the loss of his brother, Shihab al-Din Shah, must have been heartbreaking for the young Sultan Muhammad Shah, who was only seven and a half years old at the time. The sad event also evoked much grief within the Muslim community. Aqa Ali Shah was remembered fondly for the work he did towards the betterment of the community, and also as an intrepid horseman and hunter and a legend in his own lifetime. He was succeeded by his son Sultan Muhammad Shah, who became Aga Khan III.