You realize you had no legal obligation to give the cop your ID, right? You are only required to tell him your name, address, and DOB. You didn't need to follow him. He couldn't hold you. If you asked him "Am I under arrest?" he would have said no. Then you could just leave. If he said yes, you should have asked him why. He'd have nothing to tell you.

I wouldn't put up with this. Know you rights.