  Many protostellar gapped and binary discs show misalignments between their
inner and outer discs; in some cases, $\sim70$ degree misalignments have been
observed. Here we show that these misalignments can be generated through a
"secular precession resonance" between the nodal precession of the inner disc
and the precession of the gap-opening (stellar or massive planetary) companion.
An evolving protostellar system may naturally cross this resonance during its
lifetime due to disc dissipation and/or companion migration. If resonance
crossing occurs on the right timescale, of order a few Myrs, characteristic for
young protostellar systems, the inner and outer discs can become highly
misaligned ($\gtrsim 60$ degrees). When the primary star has a mass of order a
solar mass, generating a significant misalignment typically requires the
companion to have a mass of $\sim 0.01-0.1$ M$_\odot$ and an orbital separation
of tens of AU. The recently observed companion in the cavity of the gapped,
highly misaligned system HD 142527 satisfies these requirements, indicating
that a previous resonance crossing event misaligned the inner and outer discs.
Our scenario for HD 142527's misaligned discs predicts that the companion's
orbital plane is aligned with the outer disc's; this prediction should be
testable with future observations as the companion's orbit is mapped out.
Misalignments observed in several other gapped disc systems could be generated
by the same secular resonance mechanism.
