We show that a Gorenstein subcanonical codimension 3 subscheme Z ⊂ X = P , N ≥ 4, can be realized as the locus along which two Lagrangian subbundles of a twisted orthogonal bundle meet degenerately, and conversely. We extend this result to singular Z and all quasiprojective ambient schemes X under the necessary hypothesis that Z is strongly subcanonical in a sense defined below. A central point is that a pair of Lagrangian subbundles can be transformed locally into an alternating map. In the local case our structure theorem reduces to that of Buchsbaum-Eisenbud  and says that Z is Pfaffian. We also prove codimension one symmetric and skew-symmetric analogues of our structure theorems. Smooth subvarieties of small codimension Z ⊂ X = PN have been extensively studied in recent years, especially in relation to Hartshorne’s conjecture that a smooth subvariety of sufficiently small codimension in PN is a complete intersection. Although the conjecture remains open, any smooth subvariety Z of small codimension in PN is known, by a theorem of Barth, Larsen, and Lefschetz, to have the weaker property that it is subcanonical in the sense that its canonical class is a multiple of its hyperplane class. More generally, a subscheme Z of a nonsingular Noetherian scheme X is said to be subcanonical if Z is Gorenstein and its canonical bundle is the restriction of a bundle on X. There is a natural generalization to an arbitrary (possibly singular) scheme X (see below). In this paper we give a structure theorem for subcanonical subschemes of codimension 3 in PN and generalize it to subcanonical subschemes of codimension 3 in an arbitrary quasiprojective scheme X satisfying a mild extra cohomological condition (strongly subcanonical subschemes). The construction works even without the quasiprojective hypothesis. There are well known theorems describing the local structure of Gorenstein subschemes of nonsingular Noetherian schemes in codimensions ≤ 3. In codimensions 1 and 2 all Gorenstein subschemes are locally complete intersections. These results have been globalized: If X is nonsingular, any Z ⊂ X of codimension 1 is the zero locus of a section of a line bundle, while a subcanonical Z ⊂ X of codimension 2 is the zero locus of a section of Partial support for the authors during the preparation of this work was provided by the NSF. The authors are also grateful to MSRI Berkeley and the University of Nice Sophia-Antipolis for their hospitality.