Pope Francis traveled to Uganda's holiest shrine on Saturday, paying tribute to 19th century Christian martyrs killedfor their faith, including for protecting young boys in the royal court from abuse by the king.
Francis, on the second leg of his first African tour, said Mass for tens of thousands of people huddled on muddy hillsides surrounding the soaring modern shrine made of iron and cone-shaped to resemble a hut of the Baganda tribe.
Twenty-five Anglicans and 22 Catholic converts where killed during the persecutions, mostly by being burned to death, between 1884 and 1887 on the orders of King Buganda Mwanga II.
The most famous of the Catholic converts and martyrs was Charles Lwanga, a prefect in the royal court who was in charge of the boy pages and was killed because he tried to protect the children from the sexual advances of the king.
After their conversion they tried to spread the faith to other groups. Catholics now make up about 40 per cent of the population. Churches run many schools and hospitals around the country.
They did this in dangerous times," the pope said during a Mass celebrated from a concrete island on an artificial lake on the shrine complex outside the capital Kampala.
Traditional singing and dancing gave way to a Western-style church choir as the pope walked to the altar via a gangway over the lake, which was guarded by police scuba divers in dinghies.
"Not only were their lives threatened but so too were the lives of the younger boys under their care," he said.
Uganda has been seen as a bastion of anti-gay sentiment since 2013, when it sought to toughen penalties, with some lawmakers pushing for the death penalty or life in prison for some actions involving gay sex.
The law was overturned on procedural grounds, but not before US Secretary of State John Kerry compared it to anti-Semitic legislation in Nazi Germany. Other Western donors were outraged.
Gay rights activists in Uganda said before the visit that they hoped the pope would make a gesture of tolerance to homosexuals.
Failing to address the issue would be "a missed opportunity to protect LGBT persons," said activist Frank Mugisha.
In the prepared text of his homily for the Mass, the pope praised the martyrs for telling the king "what the gospel does not allow", an apparent reference to homosexual acts.
The pope, however, did not read that part of the homily. It was not clear if he decided to remove it.
The Church teaches that while homosexual tendencies are not a sin, homosexual acts are. It also says homosexuals should be respected in the Church and society but that Catholic homosexuals should remain chaste.
The pope first visited a separate shrine to the 25 Anglican martyrs before saying Mass at the nearby shrine to the Catholic martyrs, who were made saints by Pope Paul VI in 1964.
Later on Saturday, the pope was due to hold a rally with Ugandan youth and visit a Church-run home for the poor.
On Sunday morning, he is due to leave for the Central African Republic, potentially the most dangerous stop on his trip.
For nearly three years, the Central African Republic has been embroiled in an inter-religious conflict that has effectively split it in two. Thousands have been killed and more than one in five have fled internally or sought refuge abroad.