AP Photo/Alex Brandon, Pool

Sophie Cruz, 5, of suburban Los Angeles reaches to give Pope Francis a letter and t-shirt during a parade in Washington, Wednesday, Sept. 23, 2015. The massive security apparatus protecting Pope Francis on his historic, six-day trip to the U.S. got its first test Wednesday as the 5-year-old girl with a gift for the pontiff made her way through a security barrier and onto his parade route.

WASHINGTON (AP) — The massive security apparatus protecting Pope Francis on his historic, six-day trip to the United States got its first test Wednesday as a 5-year-old California girl with a T-shirt and a message about immigration for the pontiff made her way through a security barrier and onto his parade route.

Sophie Cruz of suburban Los Angeles initially shied away as a pair of security officials approached her before she was encouraged to approach the vehicle by Francis himself. Then she was quickly whisked to Francis’ modified, open-air Jeep popemobile, where the pope did what this pope so often does: He gave her a hug and kiss.

Such an encounter is routine for Francis, well known for freely wading into crowds, kissing and blessing hoisted children and eagerly accepting gifts from well-wishing strangers. But during his trip to the United States, Francis is surrounded by a phalanx of security that include suit-clad Vatican security officers and Secret Service agents, uniformed federal agents and local police keeping most onlookers at a distance.

It’s a far cry from the freewheeling motorcade routes of many of Francis’ past pilgrimages, where he would hop on and off his popemobile to kiss babies and catch soccer jerseys thrown his way from ordinary folks who had done no planning other than to show up early to get a good spot.

For the first time, tickets were required for most of Francis’ popemobile processions, and those lucky enough to get one through lotteries or their parishes still had to pass through metal detectors to get into position. Francis’ first parade in Washington was open to the general public and people lined up before dawn Wednesday to pass through security gates and stake out a spot along the route.

In New York, security screening will be just part of “layers and layers and layers of protection” the pope will receive during his visit, including a deployment of 6,000 extra police officers and specialized counterterrorism units, said John Miller, the NYPD’s top security official.

Police will also be “looking for, in the Boston Marathon example, where is the potential terrorist threat, not to the protectee, but to the crowd. And we have layers behind that,” Miller said.

The Vatican spokesman, the Rev. Federico Lombardi, said that despite the tight security Francis “intends to move around as he usually does.”

Nearly all the pope’s movements have been scripted well in advance and Secret Service agents are prepared for his inevitable spontaneous decisions to get closer to crowds along parade routes or outside other events in Washington, New York and Philadelphia, said Arnette Heintze, a retired senior Secret Service agent who worked on protection details for Presidents Bill Clinton and George H.W. Bush.

Agents “adapt and work to accommodate the needs and issues” of whomever they are protecting, whether they are political candidates wandering along a rope line or a pope who likes to mingle with fans, Heintze said.

As for Cruz’s encounter with Francis, which appeared to surprise security officers stationed nearby, Heintze said it wasn’t something to worry about.

“That’s a great moment, not a security risk,” said Heintze, who helped with advance planning before Pope John Paul II held an open-air mass in New Orleans in 1987.

Associated Press reporters Colleen Long, Jonathan Lemire and Tom Hays contributed to this report from New York.