Many thanks for your patience. First of all, you would not have had a legal right to be given the opportunity to apply for that role, even if you were already acting up in it. Secondly, employers generally have the right to choose who they employ and can make such decisions based on a relatively wide range of factors. There could be a number of reasons why one candidate is chosen in preference to others or why someone is not given a job, even if they are generally considered to be the best or most suitable candidate. In fact, it is generally lawful for the employer to use whatever factors they feel are relevant and appropriate in the circumstances to arrive at that decision.
The only requirement in law is that the employer’s decision is not based on discriminatory grounds. This means that they should not base their decision on what are known as ‘protected characteristics’. These include things like gender, race, religion, age, disability, sexual orientation, etc. If their decision is based on or linked to any of these characteristics, there will be a potential case of discrimination and the affected person can potentially take this further. However, in the absence of any discriminatory reasons, the employer will rarely be acting unlawfully and will have the general power to be selective over whom it employs, even if it this generally appears to be unfair.
I appreciate you said a male employee was given the job but that does not mean they were preferred over you because of their gender. It would very easily be a coincidence that they are male and you are female. So you would need some more evidence that gender was the reason behind their decision. As you can appreciate though, there may not be any direct evidence to back this up and it will be a bit of a speculative argument.
Should you decide to take it further the only option you have now is to consider an employment tribunal for sex discrimination, which you must do within 3 months of the alleged discriminatory act.
Does this answer your query?