Following his studies, Shamgar rejoined the army as a military prosecutor. He was appointed Deputy Chief Military Prosecutor in 1956, and Chief Military Prosecutor in 1961. Following the Six-Day War, he designed the legal infrastructure of the Israeli military government in the West Bank and Gaza Strip. He attained the rank of Brigadier General. After retiring from the military, he served as Attorney General from 1968 to 1975. In 1975, he became a judge on the Israeli Supreme Court. In 1982, he was appointed Deputy Permanent President of the Supreme Court, and in 1983, he became President of the Supreme Court. He retired in 1995.