Hammer was born in Haifa during the Mandate era. He was an active member of the Bnei Akiva youth movement (which he led), and served in the Israeli Armored Corps in a Nahal programme. He graduated from Bar-Ilan University with a BA in Judaism and Bible, as well as a teaching certificate and worked as a teacher. At the university, he headed the Student Union and was a member of the Presidium of the Israeli Students Association and the World Union of Jewish Students.
Hammer was first elected to the Knesset in 1969 as a member of the National Religious Party. He became Deputy Minister of Education and Culture in January 1973. In November 1975 he was appointed Minister of Welfare, but in December 1976 his party resigned from the cabinet