In a commencement address at the historically black university in Washington, Obama said students should not attempt to block lectures and interrupt speakers with whom they disagree.
"Don't do that," he said, "no matter how ridiculous or offensive you might find the things that come out of their mouths."
Citing the advice of his grandmother, Obama said: "Every time a fool speaks, they are just advertising their own ignorance. Let them talk."
"Listen. Engage. If the other side has a point, learn from them. If they're wrong, rebut them. Teach them. Beat them on the battlefield of ideas," the President said. "One thing I can guarantee you: You will have to deal with ignorance, hatred, racism, foolishness, trifling folks. I promise you, you will have to deal with all that at every stage of your life. That may not seem fair, but life has never been completely fair. ... And if you want to make life fair, then you've got to start with the world as it is."
In delivering his first commencement speech of the 2016 graduation season -- and the final year of his presidency -- Obama made the case that action on issues important to black students, including mass incarceration and police behavior, require careful attention to local politics and a willingness to make bargains with those who hold opposing views.
"Let me ask you: How are you pressuring members of Congress to pass the criminal justice reform bill now before them?" he said. "If you care about federal policing, do you know who your district attorney is? Do you know who your state's attorney general is? Do you know the difference? Do you know who appoints the police chief and who writes the police manual?"
Obama added: "Passion is vital, but you got to have a strategy. And your plan better include voting -- not just some of the time, but all of the time."
A call to participate
The President pointed to low voting rates among African-Americans in non-presidential election years.
"You don't think that made a difference in terms of the Congress I've got to deal with?" he said. "And then people are wondering, 'How come Obama doesn't get this done, how come he doesn't get that done?' ... You know what, just vote. It's math. If you have more votes than the other guy, you get to do what you want."
He cited Thurgood Marshall, a Howard law school graduate who went on to become the first black Supreme Court justice, noting that Marshall and his law partners filed "dozens of lawsuits" over a 20-year period before eventually winning the famous Brown v. Board of Education case, which ended school segregation.
"They knew it would not be easy. They knew it would not be quick. They knew that all sorts of obstacles would stand in their way. ... They had discipline. They had persistence. They had faith -- and a sense of humor. And they made life better for all Americans," he said.
A case for compromise
Obama also told students that demanding politicians never bend might "make you feel good" but accomplishes little.
He told the students that he often tells his White House staff that "better is good," because advancing a cause once means it's easier to do so again.
He didn't make any reference to the 2016 presidential campaign or particular politicians on Capitol Hill, but cited civil rights icon Martin Luther King Jr.'s meetings with former President Lyndon B. Johnson to hash out bargains over the Civil Rights Act and the Voting Rights Act -- even if those landmark laws didn't accomplish everything King envisioned.
"You need allies in a democracy. That's just he way it is. It can be frustrating and it can be slow, but history teaches us that the alternative to democracy is always worse," Obama said.
"This is hard to explain sometimes: You can be completely right, and you still are going to have to engage folks who disagree with you. If you think that the only way forward is to be as uncompromising as possible, you will feel good about yourself, you will enjoy a certain moral purity, but you're not going to get what you want. And if you don't get what you want long enough, you will think the whole system is rigged," leading to cynicism and anger, he said. "That's how we cheat ourselves of progress."
Obama also urged the students to empathize with "all people who are struggling, not just black people who are struggling -- the refugee, the immigrant, the rural poor, the transgender person, and yes, the middle-aged white guy, who you may think has all the advantages, but over the last several years has seen his world upended by all the economic and cultural change and feels powerless to stop it. Got to get in his head, too."
Obama touts progress
Obama began his speech with what he called a "hot take," declaring that "America is a better place today than it was when I graduated from college."
"It also happens to be better than it was when I took office, but that's a longer story. That's a different discussion for another speech," he said to laughter and applause.
The President pointed to progress over time on issues such as racism, treatment of the LGBT community and income inequality, and said "if you had to choose one moment in history in which you could be born," without knowing your circumstances ahead of time, "you wouldn't choose 100 years ago. You wouldn't choose the '50s or the '60s or the '70s. You'd choose right now."
Obama's speech drew praise from Sen. Chuck Grassley, an Iowa Republican who chairs the Judiciary Committee.
He tweeted that "even conservatives would applaud it" -- particularly the portion on campus speech.