(Adds pope's evening event, paragraphs 18-23)
By Philip Pullella and Ian Simpson
PHILADELPHIA, Sept 26 (Reuters) - Pope Francis, speaking on Saturday in America's birthplace, offered stout words of support to Hispanic and other immigrants in the United States, telling them not to be discouraged at a time when some prominent politicians are directing hostility toward them.
A day before wrapping up his first U.S. visit, the 78-year-old Argentine pontiff also used his trip to Philadelphia to promote religious freedom as a fundamental right but condemned the use of religion as a pretext for hatred and brutality.
Francis toured Philadelphia's Independence Hall before addressing a crowd estimated at more than 40,000 outside the 18th century red brick building where basic American liberties were proclaimed and independence from Britain was declared.
"Do not be discouraged by whatever challenges and hardships you face," the pope told the many Hispanics and other recent immigrants to the United States in the crowd, adding he felt "particular affection" toward them.
The leader of the world's 1.2 billion Roman Catholics urged Americans in a historic speech to Congress on Thursday to reject "a mindset of hostility" toward immigrants. He expanded on that issue in his Philadelphia speech, delivered in Spanish.
Francis said immigrants "bring many gifts" to their new nation.
"You should never be ashamed of your traditions," Francis said to applause. "I repeat, do not be ashamed of what is part of you."
Francis noted that U.S. history includes ending slavery in the 1860s and "the gradual effort to eliminate every kind of racism and prejudice directed at successive waves of new Americans."
"Remembrance saves a people's soul from whatever or whoever would attempt to dominate it or use it for their interests," he said.
Harsh rhetoric toward illegal immigrants has featured heavily in the race for the Republican nomination for the November 2016 U.S. presidential election.
Republican front-runner Donald Trump has called for deporting all 11 million illegal immigrants, most of whom are from Latin America like the pope, and has accused Mexico of sending rapists and other criminals across the border. He and many other Republicans also are advocating construction of a wall along the U.S.-Mexico border.
Philadelphia Mayor Michael Nutter told the crowd before the pope's speech, "We are all immigrants. Whether we arrived 10 generations ago or 10 minutes ago, we cannot let the xenophobia and racism of some to carry the day."
Francis, the first Latin American pope, has made the plight of immigrants a main issue of his papacy, alongside climate change, economic equality and religious freedom.
The pope spoke from the lectern used by President Abraham Lincoln for his famed 1863 Gettysburg Address after the bloodiest battle of the U.S. Civil War that declared "government of the people, by the people, for the people, shall not perish from the Earth."
Francis offered his view of religious freedom.
"In a world where various forms of modern tyranny seek to suppress religious freedom, or try to reduce it to a subculture without right to a voice in the public square, or to use religion as a pretext for hatred and brutality, it is imperative that the followers of the various religions join their voices in calling for peace, tolerance and respect for the dignity and rights of others," he said.
Outside Independence Hall, the Philadelphia Orchestra welcomed the pope with Aaron Copeland's "Fanfare for the Common Man."
The biggest crowds of his six-day visit are expected in Philadelphia, with some 1.5 million people set to attend a Mass led by the pontiff on Sunday before he flies back to Rome that night.
The pope also spoke on Saturday evening at the Church's World Meeting of Families, a festival held in a different city every three years to discuss family issues. Hollywood star Mark Wahlberg hosted the evening's program and "Queen of Soul" Aretha Franklin sang "Amazing Grace."
The pope set aside his prepared remarks for the event and talked to the audience about the importance of families.
"Families can have difficulties. Couples sometimes argue, and even plates can go flying. Children can be headaches," Francis said. "I won't even talk about mothers-in-law."
The event also included speakers who raised concerns about gay marriage, now legal in all 50 U.S. states.
An engaged Australian couple, Camillus O'Kane and Kelly Walsh, told the pope and a crowd of thousands they were concerned by an increased push to change the legal definition of marriage.
"We fear what that will mean for ourselves, our children and our society," Walsh said.
The pope traveled to Philadelphia from New York, where he flew over the Statue of Liberty, a long-time beacon for immigrants, and the former immigration station of Ellis Island aboard a helicopter in an unscheduled detour.
(Additional reporting by Scott Malone, Laila Kearney in Philadelphia and Sebastien Malo in New York; Writing by Will Dunham and Alistair Bell; Editing by Mary Milliken and Meredith Mazzilli)
Our Standards: The Thomson Reuters Trust Principles.