  In 1977, Trotter and Moore proved that a poset has dimension at most $3$
whenever its cover graph is a forest, or equivalently, has treewidth at most
$1$. On the other hand, a well-known construction of Kelly shows that there are
posets of arbitrarily large dimension whose cover graphs have treewidth $3$. In
this paper we focus on the boundary case of treewidth $2$. It was recently
shown that the dimension is bounded if the cover graph is outerplanar (Felsner,
Trotter, and Wiechert) or if it has pathwidth $2$ (Bir\'o, Keller, and Young).
This can be interpreted as evidence that the dimension should be bounded more
generally when the cover graph has treewidth $2$. We show that it is indeed the
case: Every such poset has dimension at most $1276$.
