Hara Prasad Shastri was born in Kumira village in Khulna, Bengal (now in Bangladesh) to a family that hailed from Naihati in North 24 Parganas of the present day West Bengal. The family name was Bhattacharya, a common Bengali surname.
Shastri studied at the village school initially and then at Sanskrit College and Presidency College in Calcutta (now Kolkata). While in Calcutta, he stayed with the noted Bengali scholar and social reformer, Ishwar Chandra Vidyasagar, who was a friend of Shastri's older brother
Shastri passed entrance (school-leaving) examination in 1871,
First Arts, the undergraduate degree, in 1873, received a BA in 1876 and Honours in Sanskrit in 1877. Later, he was conferred the title of Shastri when he received a MA degree. The Shastri title was conferred on those who secured a first class (highest grade) and he was the only student in his batch (class) to do so. He then joined Hare School as a teacher in 1878.