Antiochus IV Epiphanes — the Seleucid Greek king of Syria — in his attempt to Hellenize Judea by force had, in December 167 BC, set up an altar to Olympian Zeus on the great altar of the Jerusalem Temple and sacrificed a pig on it. He had Jews who refused to eat pork tortured to death. The Maccabean revolt began.
Three years later, in December 164 BC, Judas Maccabeus and his brothers — after years of guerrilla warfare in the Judean hills — recaptured Jerusalem. The Temple was cleansed, the polluted altar dismantled and its stones stored 'until a prophet should come to tell what to do with them.' A new altar was built; new sacred vessels were made. On the third anniversary of the desecration, the lights of the menorah were rekindled and the altar dedicated.
Judas and the assembly decreed that the dedication should be observed for eight days every year — the festival of Hanukkah ('dedication'). The 1 Maccabees account records the rededication; the later miracle-of-the-oil tradition (the single day's worth of consecrated oil lasting for eight days) first appears in the Talmud (Shabbat 21b). The Hanukkah miracle is the latest narrative miracle in the Old Testament canon (in the deuterocanonical Catholic-Orthodox Bibles).

