The fact that the pipe was in the car at the same time as you means, legally speaking, that you were in possession of it; the fact that it was in your hand seals the deal.
Although I've never heard of this actually working out, it's possible some leniency might be shown to you if your friend is willing to step up and state that it was his and you knew nothing about it.
Your best bet is to go into court with the aid of an attorney. Local attorneys know best what the courts want to hear, and as such have the highest potential for yielding the most favorable results. It's possible you may get some sort of deferred prosecution (don't know if Alabama offers that, but your lawyer would be able to tell you) which could mean something along the lines of some fines, taking a class, and some probation time.
The only thing worse than getting into an argument about politics is getting into an argument because you refuse to argue politics.