“Once you’ve highlighted an issue and brought it to people’s attention and shined a spotlight, and elected officials or people who are in a position to start bringing about change are ready to sit down with you, then you can’t just keep on yelling at them,” Mr. Obama said.

“And you can’t refuse to meet because that might compromise the purity of your position,” he continued. “The value of social movements and activism is to get you at the table, get you in the room, and then to start trying to figure out how is this problem going to be solved.”

Mr. Obama began his career as a community organizer working on local initiatives in poor neighborhoods in Chicago. Sometimes, he said, solving a problem means accepting a series of partial solutions.

“You then have a responsibility to prepare an agenda that is achievable, that can institutionalize the changes you seek, and to engage the other side, and occasionally to take half a loaf that will advance the gains that you seek, understanding that there’s going to be more work to do, but this is what is achievable at this moment,” he said.

It was not the first time that he has cautioned Black Lives Matter activists that social change cannot happen overnight. In a private meeting at the White House in 2014, Mr. Obama told a group of young black activists that change was “hard and incremental,” one participant said at the time.