BETHLEHEM, West Bank — When Pope Francis arrives here Sunday on his first trip to the Holy Land as pontiff, he will enter the Church of the Nativity for private contemplation at the grotto believed to mark the birthplace of Jesus Christ. He may also notice the church is falling apart.

The 1,700-year-old basilica is one of the oldest in Christendom, and the church is showing its age: The lead-covered roof leaks, the ancient rafters are rotting and water drips onto the 12th-century mosaics of hovering angels. So notorious is its decay that it was listed by the United Nations as an endangered world heritage site in 2012.

But in a kind of modern-day miracle, the three Christian faiths that share an acrimonious joint custody of the pilgrimage site – Greek Orthodox, Armenian Orthodox and the Franciscan order of Roman Catholics – were persuaded by Palestinian Authority President Mahmoud Abbas to allow Italian master craftsmen, working alongside structural engineers and wood scientists, to perform the first major documented restoration since Venetian carpenters rebuilt the roof in 1479.

Pope Francis will get a look at the progress. After five years of study and debate, the first phase of work – fixing the sagging beams and replacing the bullet-pocked windows – is expected to be complete by Christmas, at a cost of about $3 million. The money was raised by the international community and dispersed by the Palestinians, so that none of the three caretakers can claim credit – or more rights – over the church. Renovations of mosaics, doors and paintings may follow, if more funds can be secured.

One recent morning, Marcello Piacenti, a 53-year-old son of a family of Tuscan restorationists, scrambled up the scaffolding to show a visitor the wooden rafters, which were fragrant with incense and rot.

“If this was your house, naturally, you might just want to replace the whole roof. But not here. The timbers are the church,” Piacenti said.

“We have to listen to each piece of wood and hear the story it tells us,” Piacenti said. “We have been surprised so many times to see what we have found here.”

Surprises include a hole left from a stray bomb that fell in the 1967 Israeli-Arab war, as well as sophisticated 6th-century seismic retrofitting that allows the roof, even today, to “float” during an earthquake.

Also: the amount of iron nails. About seven tons of them, some two feet long. But many are nearly as sharp as the day they were hammered into the wood.

To persuade the caretakers of the church to allow the repairs, the Piacenti family is performing the restoration while keeping the church open.

The original basilica, built in the 4th century by Emperor Constantine, was leveled in the Samaritan Revolt of A.D. 529, though the floor mosaics survived. The church that stands today was constructed during the reign of Justinian in the 6th century.

It is built directly above a cave where tradition holds that Jesus was born to Mary and then laid in a manger because there was no place for them at the inn. Visitors who enter the church are herded along by monks to kneel at a subterranean altar and peer through a hole in a slab of marble to see the bedrock.

Over the centuries, the church has been besieged, burned, looted and shaken by earthquakes. It was transformed into a walled fortress by the Crusaders, who crowned their kings here.

The structure has also been beset by fungi, termites, sun, wind and rain. A Christmas storm last year dropped a foot of snow on the roof.

Piacenti lifted a cross-section of a roof beam, honeycombed with termite tunnels. The wood tells the story, he said.

The beam was constructed of larch. According to researchers at the Trees and Timber Institute in Italy, the tree that it was carved from was felled in the high-altitude forests of the eastern Alps sometime between 1440 and 1460, and then floated down a network of rivers to Venice. There, it boarded a ship bound for what is now the Israeli port of Jaffa and then traveled over land to Bethlehem.

That was the last fully documented restoration. Philip the Good, the Duke of Burgundy, paid for repairs, the Republic of Venice supplied the wood, and the carpenters and Edward IV of England donated the lead for the roof.