Add an alpha channel to the image you want to mask 'Layer -> Transparency -> Add Alpha Channel'
Right click the image layer in the layers panel, and click 'Add Layer Mask...'. The fill you choose for the mask doesn't matter at this stage - white or black will do.
Open the other image you want to use as a mask, and select all 'Ctrl + A', and copy it, 'Ctrl + C'
Back in the other image, select the layer mask thumbnail by clicking on it in the layers panel
Paste the mask you copied earlier 'Ctrl + V'
Hit the anchor icon or 'Ctrl + H', to anchor the floating selection to the layer mask.