 For higher studies, he got enrolled in Post Graduate College, Ghazipur, and completed Post Graduation from the University of Gorakhpur.Ansari's father Subhanullah Ansari was chairman of Nagar Palika Parishad, Mohammadabad who got elected unopposed.His grandfather Mukhtar Ahmed Ansari served as the president (1926-1927) of the Muslim League, as well as the Indian National Congress, and was one of the founders of the Jamia Millia Islamia, New Delhi who remained its chancellor from 1928 to 1936.