Historic north-east jewel’s future in Scotland secured following auction