The first church over the cave was built in the reign of Constantine and dedicated in the 330s. It burned or was destroyed in the sixth century and Justinian replaced it with the larger basilica that still stands, its columns and much of its plan unchanged since. A well known tradition holds that the building survived the Persian invasion of 614 because the invaders recognised their own dress in a mosaic of the magi above the door; the mosaic is long gone and the story cannot be confirmed, but the church did survive when others did not. Crusader mosaics and painted columns remain on the walls, and the main entrance was reduced over the centuries to the low opening called the Door of Humility, which a visitor must stoop to pass.
The church is shared by the Greek Orthodox, Armenian Apostolic and Roman Catholic communities under the arrangement known as the Status Quo, a freeze on rights of possession, procession and cleaning that was codified by Ottoman decree in the nineteenth century after disputes over the building, including the theft of the silver star from the grotto, became an international incident. Nothing in the church may be repaired by one community alone, which is why straightforward maintenance took until a joint restoration agreed in 2013.
The town today lies in the West Bank behind the separation barrier. Its Christian population has fallen sharply within living memory, and the church became the first Palestinian site inscribed on the World Heritage list in 2012, entered directly onto the list of sites in danger.