Pope Francis waves as he leaves Casal del Marmo prison in Rome after a mass of the Lord's Supper on Holy Thursday. Photograph: Andreas Solaro/AFP/Getty Images

Two young women were among 12 people whose feet Pope Francis washed and kissed at a traditional ceremony in a Rome youth prison on Holy Thursday, the first time a pontiff has included females in the rite.

The pope travelled to the Casal del Marmo prison on Rome's outskirts for the traditional mass, which commemorates Jesus's gesture of humility towards his apostles the night before he died.

The ceremony has been traditionally limited to men because all of Jesus' apostles were male. The Vatican spokesman said two of the 12 whose feet were washed were Muslim inmates.

While the former Cardinal Jorge Bergoglio included women in the rite when he was archbishop of Buenos Aires, it was the first time women had taken part in a papal Holy Thursday ceremony.

Taking the ceremony to a youth prison was also a papal first and Francis, who was elected only two weeks ago, said he wanted to be closer to those who were suffering.

All popes in living memory have held the service either in St Peter's or the Basilica of St John in Lateran, which is the pope's cathedral church in his capacity as bishop of Rome.

In a brief, unscripted homily, the pope told the young inmates that everyone, including him, had to be in the service of others.

"It is the example of the Lord. He was the most important but he washed the feet of others. The most important must be at the service of others," he said.

At a mass in the Vatican on Thursday morning, Francis urged Catholic priests to devote themselves to helping the poor and suffering instead of worrying about careers as Church managers.

His homily at his first Holy Thursday service as Roman Catholic leader was the latest sign since his surprise election two weeks ago of his determination that the 1.2 billion-member Church should be closer to the poor.

"We need to go out, then, in order to experience our own anointing (as priests) … to the outskirts where there is suffering, bloodshed, blindness that longs for sight, and prisoners in thrall to many evil masters," he said during a mass in St Peter's Basilica.