In a historic speech to the U.S. Congress, Pope Francis on Thursday asked Americans to end hostility towards immigrants, jumping into a divisive debate about how the country should deal with millions of undocumented workers and their families.

Bringing a message that America's power and wealth should be used to serve humanity, the Argentine pontiff said the United States must not turn its back on "the stranger in our midst."

"Building a nation calls us to recognize that we must constantly relate to others, rejecting a mindset of hostility," the 78-year-old Francis told the Republican-dominated legislature.

​Francis, born to an Italian immigrant family in Argentina, delivered a wide-ranging speech that addressed issues dear to liberals in the United States but also emphasized conservative values and Catholic teachings on the family.

The leader of the world's 1.2 billion Catholics called for a more equitable economy, greater effort against climate change, and an end to the death penalty globally.

His plea on immigration received frequent applause mostly from Democrats, but also from Republicans among the lawmakers, Supreme Court justices and other dignitaries packed into the House of Representatives to hear the first address by a pope to the U.S. Congress.

Harsh rhetoric toward illegal immigrants has featured heavily in the race for the Republican nomination for the November 2016 presidential election.

Republican front-runner Donald Trump says he would deport the 11 million undocumented immigrants if he were elected to the White House and has accused Mexico of sending rapists and other criminals across the border.

Speaking softly and in heavily accented English, Francis drew on America's history as a country made by immigrants and said it should not be put off by the number of foreigners, especially from Latin America, who are trying to make it their home.

"We must not be taken aback by their numbers, but rather view them as persons, seeing their faces and listening to their stories, trying to respond as best we can to their situation. To respond in a way which is always humane, just and fraternal," he said.

Pope Francis addresses a joint meeting of Congress on Capitol Hill in Washington, Thursday, making history as the first pontiff to do so. Listening behind the Pope are Vice-President Joe Biden and House Speaker John Boehner. (Carolyn Kaster/Associated Press)

As he spoke, Francis was flanked by two of America's most influential Catholics: House Speaker John Boehner, a Republican, and Democratic Vice-President Joe Biden. Boehner, who often tears up at emotional moments, cried openly during the speech.

Several Republican presidential candidates were in the audience, including retired neurologist Ben Carson, New Jersey Gov. Chris Christie and Senator Marco Rubio, son of Cuban immigrants.

The United States has grappled for years over what to do with 11 million or so undocumented immigrants, most of them Hispanic.

Republicans in Congress last year blocked a bipartisan effort to overhaul immigration laws that would have allowed illegal immigrants a chance to win U.S. citizenship.

Around that time, more than 60,000 unaccompanied minors from Central America sparked a crisis when they rushed to the U.S. border hoping to get in.

Michael Tipsword, a student at George Washington University and a Catholic, said Francis' opinion on immigration is more related to humanitarian needs than politics.

"It doesn't affect my thoughts" on immigration, said Tipsword. "I'm a pretty staunch conservative," he said, standing on the lawn in front of the Capitol building where thousands watched the speech on a large video screen.

Pope Francis is greeted by Trenton Shepherd of Washington, who kisses his hand, on his arrival at St. Patrick's Church on Thursday. (Mike Theiler/Associated Press)

Invoking famous American political figures Abraham Lincoln and Rev. Martin Luther King Jr., Francis told U.S. lawmakers who are often caught up in bitter partisan fights that politics should be "an expression of our compelling need to live as one, in order to build as one the greatest common good."

Presidential candidates from both sides of the divide held up the Pope's comments as evidence that the leader of America's 70 million Catholics agrees with them.

In remarks welcomed by conservatives, Francis said, "Fundamental relationships are being called into question, as is the very basis of marriage and the family," expressing his opposition to same-sex marriage.

In reference to abortion and euthanasia, the Pope said humanity must "protect and defend human life at every stage of its development."

Texas Republican Senator Ted Cruz, a 2016 White House hopeful, took a dig at Democratic rivals in Congress.

CBC's Paul Hunter asks people about the pontiff's remarks on the environment 1:36

To New York tonight

"It was striking and heartbreaking to see so many congressional Democrats sitting, stone-faced, arms crossed, when the Pope urged us all to defend human life," he said.

A frequent critic of the damage caused to the environment by capitalism's excesses, the Pope reiterated remarks he made at the White House on Wednesday, that the United States has an important role to play to "avert the most serious effects of the environmental deterioration caused by human activity."

To underscore his message of helping the poor, Francis went straight from Congress in his small black Fiat to have lunch with homeless people, telling them there was no justification for homelessness.

Later on Thursday, the Pope flies to New York, where he will attend prayer services at St. Patrick's Cathedral. Francis will address the United Nations General Assembly on Friday and celebrate an open-air Mass in Philadelphia on Sunday.