Ramanujan and the Modular $j$-Invariant A new infinite product $t_n$ was introduced by S.~Ramanujan on the last page of his third notebook. In this paper, we prove Ramanujan's assertions about $t_n$ by establishing new connections between the modular $j$-invariant and Ramanujan's cubic theory of elliptic functions to alternative bases. We also show that for certain integers $n$, $t_n$ generates the Hilbert class field of $\mathbb{Q} (\sqrt{-n})$. This shows that $t_n$ is a new class invariant according to H.~Weber's definition of class invariants. Keywords:modular functions, the Borweins' cubic theta-functions, Hilbert class fieldsCategories:33C05, 33E05, 11R20, 11R29