As you move up the career ladder, you are going to confronted with this scenario many times. It is always a good sign that you want to move ahead and the fact that you are putting yourself forward will be looked upon favourably by senior management.
But you will always need to demonstrate a level of maturity and professionalism when competing against a colleague for that next step.
Be Objective in Your Assessment of Your Own Skills
Are you really ready for this role (that means are you 70% ready) or are you putting yourself forward because you feel that you should or that it is simply more money but your skillset is not anywhere near what the job entails?
If it is the latter, I would advise against it but I would speak to the hiring manager and let him/her know that you are working towards this skillset and to keep you in mind for the future (you never know - they may adjust to responsibilities to a level closer to your skill set if they have heard good things about you).
If you really feel you are ready but there is a colleague also applying for the role - what do you do? In assessing your own skills, do you feel that you are more or less qualified than this candidate? Are there politics (there always are) that are at play to favour one or the other.
My advice is that if you really feel that you are ready, you should always good for it. The fact that you are pursuing career development and are being practical and honest about your skill-set, this can never hurt you.
Professionalism and Maturity
So you both apply and now it's awkward. Always, always take the higher road. Don't get dragged into a nasty, political, cloak and dagger scenario where you both are trying to rally people against each other. Whomever gets the job will have to work with the other and should be mature to realise that the other person is an asset. The person can be a potential successor and if groomed correctly can make you look (and the team) good. Their success is your success and when you want to step up to the next role, you better have a successor ready!
If you do not get the job, you should immediately congratulate the other person (even if deep down you are seething). It immediate tells the person that you are on their side and are not going to pose a problem for them.
You can demonstrate maturity by asking the hiring manager for tips as to what you would need to improve on the secure the post the next time. They will remember how well you handled this.