Masks allow you to show specific portions of other layers. It's like laying a stencil down on the sidewalk, painting over the stencil, and then lifting away the stencil. In this example the stencil is the mask.
Masks use the alpha channel of the paints and/or the outline of the shape to mask the layers above. Since only PNG files store an alpha channel, a JPG doesn't really work as a mask.
You can convert any boolean group, group, or shape to a mask by selecting the layer and clicking the Mask button in the toolbar or by right-clicking on the layer and selecting Use as Mask.
Masks naturally limit, the visibility of their siblings, and they intersect with any parent masks that are applied. Top-level masks are inserted into a group to prevent the entire canvas from disappearing into the mask. Clipped groups also stop mask propagation.
Figma supports both outline and alpha masks. Both share the geometry outline, but alpha masks use the per-pixel opacity of the paints.
Watch this short video demonstrating how to make a simple outline mask.
Outline masks use the outline of the shape being used as the Mask. The mask will apply to all layers above them in the layers panel until they hit a component. When you select something to be used as the Mask, it will be invisible on the screen, so typically you'll need to duplicate them.
Currently, masks do not support effects (i.e. gradients, shadows, blurs, etc).