That's right, and sometimes standing up for someone means having to pay a price yourself. It sucks that you got a detention, but you can go away knowing you did the right thing and you've proven yourself to be a friend.
I hope you'll be able to avoid the wrath of your teacher from here on out. He doesn't sound worth risking your own record over.