After graduating he was appointed special agent of Jewish affairs to the governor-general Aleksandr Potapov, an office which afforded him the opportunity of bringing about an improvement of the condition of the Jews.
After the death of the government rabbi of Vilna, Ephraim Kahan, Gerstein was elected his successor, and in that capacity signed, with others on 4 November 1860, the prohibition against translating the Mishnah into Yiddish.
Gerstein resigned in 1861, and was made superintendent of the Talmud Torah of Vilna, the administration of which he reorganized.
He succeeded in collecting considerable sums, and by this means so increased the number of pupils of the school that it became necessary in 1882 to erect a new building.
In 1890 he founded a technical school in which the pupils of the Talmud Torah, after finishing their studies, might acquire a handicraft.