Sure, ask, but ask right -- and "why was I rejected" is probably wrong.
In all likelihood, you weren't 'rejected' as much as someone else was 'selected' as being better matched to their needs.
So the proper, non-neurotic way to ask would be something like: "Thanks for your consideration. I was very enthusiastic about your position and it's still the kind of job I'd like to find. Can you share with me any ways I could be a better candidate for similar positions in the future?"
This gives the best chance they'll mention a couple things important in their evaluation where you could improve. (If you're really lucky, they may mention the exact things that caused them to prefer someone else.)
Also: don't take it personally if they say little, if at all. A sentence or two may be the most to hope for unless you have a strong relationship with an insider. Most organizations are risk-averse in hiring and being too detailed in a "sorry, you're not hired" explanation risks triggering resentment, argument, possibly even a lawsuit.