The rules for the Pope's security during international trips have had to change since Pope Francis was elected, bringing into focus the tension between safety and pastoral priorities.

When he was Archbishop of Buenos Aires, then-Cardinal Jorge Bergoglio walked through the streets, and took buses and the subway, so when he became Pope he did not want to follow the normal security protocols and asked his security team to allow him to be "as close to people as I can."

And those new rules were evident on July 22, the first day of the Pope's visit to Rio de Janeiro for the 28th World Youth Day.

The regular security procedures required Pope Francis to travel from the airport to Rio de Janeiro's downtown in the so-called popemobile, a special car that permits onlookers to see him, while also keeping the pontiff protected behind bulletproof glass.

But Pope Francis found this way of moving to be too far removed from people. He did not want to use the popemobile, and preferred to use a small car as he does when he is in Rome, where he uses a Ford Focus.

In the hours that followed, crowds of eager pilgrims broke through security lines and stopped his car as they tried to touch the Pope and greet him. The papal convoy also ended up taking a wrong turn and getting stuck in traffic, a turn of events that alarmed the security detail.

Pope Francis, on the other hand, seemed to be pleased to be so enthusiastically welcomed, going so far as to lower the windows of his car to make physical contact with the people who approached his car.

Luckily, nothing happened.

In a July 23 news release the Brazilian authorities denied responsibility for the diversion in the Pope's itinerary and attributed the decision to "the wish of the Holy Father to stay in touch with the most people he can."

But the fact is that the Brazilian security forces are being strongly tested by Pope Francis' unpredictability.

Yesterday, for example, Pope Francis had no official appointments scheduled, but he suddenly announced that he wanted to visit Corcovado, the mountain near Rio de Janeiro where the famous Christ the Redeemer statue stands.

It would have been a risky outing since a forest surrounds Corcovado and the access points to it are narrow, as well as the fact that the security detail would have had little time to plan the outing.

But the security personnel were able to convince the Pope that it was not a good idea to go because of the weather and cold temperatures.

It is likely that the coming days will present more divergences from the Pope's itinerary, not less, as he alluded to during the flight to Rio de Janeiro, telling journalists that "there will be a lot" of unscheduled events.

The careful balance between safety and bringing the Pope's ministry to the people has a long history.

In 1964, during his visit to Jerusalem, the crowd separated Pope Paul VI from his bodyguards. Paul VI wanted to walk on foot along the "Via Dolorosa" that Jesus took as he ascended Mount Calvary.

The Pope ended up being completely surrounded by a crowd, so the Jordanian soldiers protecting him led him into the nearby Church of the Holy Sepulcher.

During his trip to Philippines in 1970, a deranged Bolivian tried to assassinate Paul VI with a knife.

The Pope's life was saved by Monsignor Paul Marcinkus who helped fight off the attacker. Later, Paul VI acknowledged how grateful he was by appointing Msgr. Marcinkus the head of the Institute for Religious Works, the so-called Vatican bank.

John Paul II was also the target of two assassination attempts: the first was carried out by Mehmet Ali Agca in Rome on May 13, 1981, while the second was attempted by a Spanish priest, Juan Maria Fernandez y Krohn, in Fatima on May 12, 1982.

These kinds of episodes and the inevitable demonstrations by groups trying to grab the international news spotlight resulted in a strengthening of the security protocols during the papal visits.

Although no large-scale protests are expected in Rio during Pope Francis' visit, several demonstrations against the Brazilian government are planned.

These manifestations first appeared while the Pope was visiting President Dilma Roussef on July 22, but the protestors were repelled by tear gas after one of them reportedly lobbed a Molotov cocktail at police.

According to Father Federico Lombardi, director of the Holy See Press Office, the Pope "had to use a helicopter to avoid the protestors" as he left the governmental palace.

On Sunday, the day before the Pope's arrival, a homemade bomb was discovered in a public bathroom adjacent to a parking lot at the Marian shrine of Aparecida, where the Holy Father is paying a visit on Wednesday morning.

In fact, an attempted bombing or attack against the Pope is often tried during a papal trip.

When Benedict XVI went to London in 2010, together with reports on the protests against the Pope's visit came the news that police arrested six men for allegedly plotting to attack the Pope.

In 2011, before the Benedict XVI's trip to Germany, two Muslims were arrested while allegedly planning to make a chemical bomb to attack the Pope.  

However, an Italian policeman who is familiar with papal trips and who asked for anonymity told CNA July 23 that "those bombs are made to be found, not to explode. There are often secret services that place the bomb, so the police can find and defuse the bomb or arrest alleged people, thus gaining more trust from the population and a sense of general tranquility which can avoid riots."