Yes. It is called "deselection".
Parties can stand whatever candidate they like in each constituency. It is empirically the case that the previous incumbent, running as the same parties' candidate, is more likely to win, than a replacement, so the normal practice is to run the incumbent again if they desire.
Having been deselected against ones will, it is perfectly possible to run against the other selected candidate. This will either be as an independent, or for a different party. This does have the problem of splitting the vote, and often means someone else wins.
Threats of this kind are currently being used by constituency Labour parties1, to align "Blarite" and "Brownite" MPs to become more "Corbynite". This pressure was named as a reason why some of MPs left Labour (to form "The Independant Group" with some ex-Conservatives)
Also currently facing deselection is the Conservative MP Nick Boles, for being too "Remain".
1 Under Labour rules, local party members get much of the choice of whom to stand as the official Labour candidate.