How does nibbāna relate to the 31 lokas and does rebirth into higher realms of existence precede enlightenment or result from it? Many thanks.
The higher realms are not directly related to enlightenment although some higher realms (such as the moral humane 'human' realm or the meditative jhana 'godly' realm) can help with reaching enlightenment. Thus, some (but not all) higher realms precede enlightenment rather then result from enlightenment.
The word 'existence' or 'bhava' generally refers to attaching to things as 'self' thus, as described in AN 4.123, for example, any attachment, self-becoming or 'ego-existence' in a higher realm will eventually lead to 'hell' ('suffering'; 'torment'; 'despair').
In short, enlightenment cannot precede from or result in any kind of 'existence' ('bhava') since enlightenment ends 'ego-existence'.