  In this paper, first we introduce the notion of a twilled 3-Lie algebra, and
construct an $L_\infty$-algebra, whose Maurer-Cartan elements give rise to new
twilled 3-Lie algebras by twisting. In particular, we recover the Lie
$3$-algebra whose Maurer-Cartan elements are O-operators (also called relative
Rota-Baxter operators) on 3-Lie algebras. Then we introduce the notion of
generalized matched pairs of 3-Lie algebras using generalized representations
of 3-Lie algebras, which will give rise to twilled 3-Lie algebras. The usual
matched pairs of 3-Lie algebras correspond to a special class of twilled 3-Lie
algebras, which we call strict twilled 3-Lie algebras. Finally, we use
O-operators to construct explicit twilled 3-Lie algebras, and explain why an
$r$-matrix for a 3-Lie algebra can not give rise to a double construction 3-Lie
bialgebra. Examples of twilled 3-Lie algebras are given to illustrate the
various interesting phenomenon.
