We're sure it's hard to understand why you were passed over for this promotion, when it appears you were the logical choice in terms of seniority. You have shown you're proactive and have ambition. Even though it may appear that your strategy of taking on a tough assignment has failed, we don't think you've done yourself a disservice in doing so. Most employers value employees who are willing to tackle challenges.
First, before deciding whether it's time to jump ship, you should talk frankly with your immediate supervisor (or the person who made the decision to promote the other person) and find out exactly what criteria they used in formulating their decision. If he or she is honest with you and explains the decision-making process, you'll know if there's a future for you that will meet your needs and hopes, or if you've, in fact, gone as far as you can with this company. Second, ask them what they see for you for the next 12 to 18 months. It's possible that there is another plan for you that will give you the promotion and added responsibilities you desire. Third, find out what concrete steps you can take now to get results that will enable you to stay with this company and be happy and productive.
If, however, your supervisor isn't willing to talk with you, or you feel the response somehow isn't honest or is blatantly unfair, begin to make immediate plans to find out what you're worth in the job market and see what other possibilities interest you. Then undertake a thoughtful and well-planned job search, while continuing to finish up the job you've started for your present company.