A playful Pope Francis, invoking the words of the Rev. Martin Luther King Jr. in a meeting with a group of East Harlem elementary school students Friday afternoon, implored New York's inner-city children: "Don't stop dreaming."

"Very near here is a very important street named after a man who did a lot for other people. I want to talk a little bit about him. He was the Reverend Martin Luther King. One day he said, 'I have a dream,'" Francis said, in Spanish, to the children at the Our Lady Queen of Angels Catholic school.

"His dream was that many children like you could get an education," Francis said. "It is beautiful to have dreams and to be able to fight for them."

Pope Francis took the time to laugh, play and take lots and lots of selfies, with hundreds of students who gathered for his visit.

Arriving at Our Lady Queen of Angels around 4 p.m., the pontiff spent several minutes walking up and down a sidewalk crowded with schoolchildren -- shaking their hands, blessing them and posing for pictures with them. They chanted "Holy father, we love you," and sang "When the Saints Go Marching In."

Once inside the school, children sang, "Make Me a Channel of Your Peace." When their energy appeared to drop, Francis cupped his ear and gestured for them to sing louder.

When they didn't, he joked that they appeared sleepy, leaning his head onto his hands. The children finally turned up the volume, and the pontiff bopped his head along with the song.

Francis met with a group of about two dozen third- and fourth-graders and marveled at projects they prepared in his honor showcasing stewardship, community service and the environment. At one point, he tinkered with a touch-screen art project, moving items around a digital painting of a river.

When one child told him he was from Argentina, Francis' eyes widened, and he gave the boy a thumbs up.

Dignitaries including Cardinal Timothy Dolan and Mayor Bill de Blasio attended the visit.

After spending time in a classroom, he moved to the school's gym, where Catholic Charities organized an event with several immigrants from various nations. They presented him with gifts, including a blue soccer ball. A young man asked the pope which was his favorite team. He answered, "San Lorenzo" -- a team based in Buenos Aires.

Taking to a stage, Francis thanked the students and their teachers for inviting him.

"I am very happy to be with you today, along with this big family which surrounds you," said Francis, who spoke of school as being a "second home" for children.

"This is not only important for you, but also for your families," he said. "School then ends up being one big family. One where, together with our mothers and fathers, our grandparents, our teachers and friends, we learn to help one another, to share our good qualities, to give the best of ourselves, to work as a team and to pursue our dreams."

Departing from his prepared remarks at times, Francis spoke of Jesus being a source of joy, and asked them who, then, "sows seeds of sadness?"

"The devil," he said. "He doesn't want happiness. He doesn't want you to dream."

Before departing, Francis said he had one "homework" assignment for the schoolchildren. "Please don't forget to pray for me, so that I can share with many people the joy of Jesus."

Francis then encouraged audience members to sing for him, and some did. He then led the room in reciting the "Our Father."

Earlier, a bright rainbow broke through the cloudy haze in the skies above East Harlem F, where hundreds of worshippers anxiously awaited Pope Francis' arrival.

The mostly black and Hispanic followers gathered up 12-rows deep along the sidewalks of Third Avenue, lined with laundromats, 99-cent stores and nail salons. Many waved U.S., Puerto Rican and Vatican City flags. Others watched from out the windows of their tenement apartments.

It was as close as they could get to Our Lady Queen of Angels on 12th Street.

School officials said about two dozen pupils from the school won a lottery to meet, speak and pray with the pope.

"It is an honor and a blessing. The blessing of his presence in our school will have a lasting effect," principal Joanne Walsh said in a statement.

Hundreds more students and educators from inner-city Catholic elementary and high schools were outside Our Lady Queen of Angels to greet Francis. The students were selected by their school administrators because of their active religious lives and community work. They are altar servers at school and church Masses, volunteers helping the homeless and elderly, and tutors for younger students.

The other schools represented include the St. Ann School, the St. Charles Borromeo School and the St. Paul School -- all in Manhattan. The schools will present the pope with a "spiritual bouquet" collection of prayers, photographs and drawings by the students bound in a hardcover book.

Timothy McNiff, superintendent of schools for the Archdiocese of New York, said recently that he hopes the pontiff's visit will highlight the successes of a Catholic school education and the opportunity the schools provide in inner-city neighborhoods as a "doorway out of poverty."

Sixty schools in the archdiocese have been closed since 2011 because of fiscal hardships. McNiff said a new funding strategy has parishes donating a portion of Sunday collections to schools, and a new leadership structure has prevented further closings.

Our Lady Queen of Angels has faced its own challenges. Its church closed eight years ago because of declining attendance. Residents of its low-income neighborhood have unsuccessfully fought to reopen it since.

Joseph Zwilling, the archdiocese's spokesman, said that there are no plans to reopen Our Lady Queen of Angels Roman Catholic Church, nor to demolish it.

"The church remains a church without a parish," Zwilling said. "It is occasionally used by the school and by the sisters."

The school visit comes in the middle of a busy day for the 78-year-old head of the Catholic church. Earlier Friday, Francis addressed the United Nations General Assembly, and later visited the National September 11 Memorial & Museum in lower Manhattan.

Following his visit to the school, the pope is scheduled to take part in a procession through Central Park before leading an evening Mass at Madison Square Garden.