Zuckerberg was giving the commencement address at Harvard, where he first created the social network in 2004.
He said: "We live in an unstable time. There are people left behind by globalisation across the world. It's hard to care about people in other places if we don’t feel good about our lives here at home. There’s pressure to turn inwards.
"This is the struggle of our time. The forces of freedom, openness and global community against the forces of authoritarianism, isolationism and nationalism. Forces for the flow of knowledge, trade and immigration against those who would slow them down.
"This is not a battle of nations, it's a battle of ideas. There are people in every country for global connection and good people against it."
Meanwhile, Apple chief designer, Sir Jonathan Ive, has said in an interview with the BBC that it is vital for the UK to remain open to talent from around the world, if it wants to remain a leader in the tech industry.
Ive said: "That general principle [on access] is terribly important for creating a context for multiple companies to grow and in a healthy way explore and develop new products and new product types."
Theresa May, who pollsters expect to win next month’s general election with an increased majority, has said she will take the UK out of the single market and end free movement – a change that may have an impact on the ability of companies to hire international employees.
Ive has just been appointed chancellor of the Royal College of Art.