U.S. Secretary of State John Kerry told Northeastern University graduates on Friday that their diversity is "Donald Trump's worst nightmare" and that it's their job to stop the spread of violent extremism.

Speaking to an estimated audience of 25,000 at Northeastern's 114th commencement ceremonies, Kerry drew heavy applause when he noted the many races and religions among the graduates, and then directed a jab at the de facto Republican presidential nominee.

"I want you to just look around you," he said. "Classmates from every race, religion, gender, shape, size. Eighty-five countries represented and dozens of languages spoken. You are the most diverse class in Northeastern's history. In other words, you are Donald Trump's worst nightmare."

Trump has angered many by comments he has made about Hispanics and Muslims, among other groups. He backs building a wall along the U.S.-Mexico border and wants to deport the millions of people in the U.S. illegally. He has also proposed banning Muslims from entering the U.S.

Kerry alluded to Trump again, saying the U.S. "will never come out on top if we accept advice from soundbite salesmen and carnival barkers who pretend the most powerful country on Earth can remain great by looking inward."

The Democratic secretary of state assured graduates that the United States and its allies are winning the battle against extremists in Iraq and Syria. But he added that the U.S. won't be successful in the long run if the world continues to turn away from other problems that fuel the production of terrorists at what he said is an "alarming" rate.

"Your mission is to make jobs not just in a few places but many places," he said. "Doing this is not about charity, it's not about giving something for nothing. It's about building our own security and preventing the conflicts of the future."

During his speech at Boston's TD Garden, Kerry praised the work of President Obama's administration on climate change and public health, but he called on graduates to go further.

He blasted climate change deniers and called the issue "one of the greatest challenges of our time." He added that the global agreement on climate change reached in Paris last year is only the start of the solution.

"Last March was the hottest March in recorded history. Last year was the hottest year in recorded history," he said. "The facts are simply staggering."

Kerry, who became secretary of state in 2013, was a longtime U.S. senator from Massachusetts and was a prosecutor in the state. He earned a law degree from Boston College in 1976 after graduating from Yale University.

He previously delivered the commencement address at Northeastern in 2000. Friday's address was Kerry's first speech at the TD Garden since he accepted the Democratic presidential nomination there in 2004.

Talking for a half-hour, Kerry described a world filled with heavy challenges. He drew on the spread of the Zika virus, the wide gap between rich and poor and the 2013 Boston Marathon bombing.

"Boston and Northeastern need no lesson in how important it is to win the battle against terrorists," he said. "There can be no peace without eliminating this scourge."

But he added that the graduates have the education and character to confront those challenges, and he urged them to play a role in the global community. He ended on an optimistic note, paraphrasing former South African President Nelson Mandela.

"All the hardest jobs seem impossible until they are done," Kerry said.

With reporting by WBUR's Steve Brown