CAMDEN, N.J. — President Obama came here on Monday to celebrate the progress a revamped police force has made in building trust between law enforcement and the people of Camden, a rare bright spot in what he has acknowledged is an otherwise troubled relationship between the police and black communities.

But as the presidential limousine passed through street after street of decrepit buildings, stopping at a community center so he could talk to young black men and police officers, Mr. Obama confronted a set of problems that have helped define his own complicated relationship with the police.

Ever since he said in 2009 that the police “acted stupidly” in arresting Henry Louis Gates Jr., a black Harvard professor who is a friend of Mr. Obama’s, outside his Cambridge home, there has been a sense among at least some law enforcement officials that Mr. Obama is not on their side, and is suspicious of them and disdainful of their culture.

As racially tinged clashes between black men and police officers have cropped up in cities throughout the country, Mr. Obama has tried to strike a delicate balance in condemning inappropriate police practices without making a blanket condemnation of their profession. Law enforcement officials say he has often fallen short.