How Samaritans and Jews came to be separate is disputed, and each tradition has told it as the other's apostasy.
Samaritan tradition holds that the two were one until the priest Eli left Mount Gerizim for Shiloh and established a rival sanctuary, an act it places in the period of the judges. On this account the Samaritans are the ones who stayed and Judaism is the innovation.
Jewish tradition, drawing on the account in the second book of Kings, holds the reverse: that when Assyria destroyed the northern kingdom of Israel in 722 BCE and deported part of its population, foreign settlers were brought in, took up a partial worship of the God of Israel, and are the ancestors of the Samaritans. The name given them in rabbinic literature, Kutim, encodes that claim.
Modern scholarship accepts neither account as it stands. The Assyrian deportations did not empty the north, where Israelite population certainly continued. The prevailing view treats Samaritans and Jews as two branches of a common Israelite religion that diverged gradually through the Persian and Hellenistic periods, the break becoming irreversible only late in that process. Genetic studies of Samaritan male lines have found them closely related to Jewish ones, which fits continuity rather than replacement.
Archaeology has sharpened the picture. Excavations on Mount Gerizim uncovered a sacred precinct in use from about the fifth century BCE and greatly enlarged in the early second, with a substantial city around it. The Hasmonean ruler John Hyrcanus destroyed the sanctuary late in the second century BCE, though Josephus and the coin evidence differ by roughly two decades on the date, and it was never rebuilt. That destruction is generally taken as the point at which the separation hardened past repair.