In some circumstances, if your staffing is out of balance and the Fair Employment Act 1976 applies to you, you would not be able to advertise the role internally as to do so would perpetuate the imbalance.
You would have to advertise externally, widely, and in such a manner that people from under-represented parties would have a chance off seeing it. You would, however, have to appoint the best candidate – but you could not appoint someone because of their religion/race/sex and so on.
Legislation in the rest of Great Britain allows for advertising to under-represented minorities in terms of religion/race/sex, if you recognise through equal opportunities monitoring that you have an imbalance problem.
Certainly no vacancy has to be offered internally first (unless you have given some assurance so to do – perhaps through contractual terms or a union agreement, although I have never come across such an arrangement). I would, in any event, favour advertising both internally and externally. External adverts give you a chance to bring in fresh blood and fresh ideas – always a good thing – even if it does occasionally put an internal candidate’s nose out of place.