Numerical simulations of global three-dimensional (3D), self-gravitating discs with a gap opened by an embedded planet are presented. The simulations are customized to examine planetary gap stability. Previous results, obtained by Lin & Papaloizou from 2D disc models, are reproduced in 3D. These include (i) the development of vortices associated with local vortensity minima at gap edges and their merging on dynamical time-scales in weakly self-gravitating discs, (ii) the increased number of vortices as the strength of self-gravity is increased and their resisted merging, and (iii) suppression of the vortex instability and development of global spiral arms associated with local vortensity maxima in massive discs. The vertical structure of these disturbances is examined. In terms of the relative density perturbation, the vortex disturbance has weak vertical dependence when self-gravity is neglected. Vortices become more vertically stratified with increasing self-gravity. This effect is seen even when the unperturbed region around the planet's orbital radius has a Toomre stability parameter ∼10. The spiral modes display significant vertical structure at the gap edge, with the mid-plane density enhancement being several times larger than that near the upper disc boundary. However, for both instabilities the vertical Mach number is typically a few per cent, and on average vertical motions near the gap edge do not dominate horizontal motions.