I stood up for a buddy's wedding in Brooklyn a few years ago. The bride and groom stayed in a hotel that night and I crashed in their apartment. Their downstairs neighbors knew they had gotten married that day, knew they were going to be staying in a hotel, knew they were leaving for their honeymoon. They did not know that I was going to be staying in the apartment and so, justifiably, called the police when they heard me stumbling around.
So I pass out on the couch and about ten minutes later there's a knock on the door and more flashlights than the NBC Sunday Night Mystery Movie. I open the door in my boxers and there's six (6!) cops. They ask me if I lived there, I say no, my friend just got married, I'm in from out of town and staying at his place. They apologize for the confusion and leave.
They didn't ask me to step outside, they didn't ask me for ID, they didn't ask for proof of residence. My story fit with the neighbor's story so they let it go.
But the most salient fact is probably that I opened the door in my boxers having clearly been asleep which is remarkably atypical behavior for someone breaking and entering. Just like Gates. Guy goes to open his door with his cane and his pink shirt and his gray beard...

... in the middle of the day... common sense, which the police are supposed to have, dictates that maybe this guy is not an intruder. So, yeah, the cop behaved stupidly. Did Gates help ease the situation? No. Is that his responsibility? Hell no. He was on his property, in his house and had committed no crime.
For some helpful tips on Massachusetts laws, check out slate.
http://www.slate.com/id/2223379/
Another article from Slate which pretty much sums up everything from this thread.
http://www.slate.com/id/2223472