It turns out the answer can be found in the paper "COMPACT ELEMENTS AND CARTAN SUBGROUPS OF CONNECTED LIE GROUPS" by Kabenyuk. The argument goes as follows.
Let $K$ be a maximal compact subgroup of $G$, and $T$ be a maximal torus in $K$. There exists a Cartan subgroup $H$ of $G$ that contains $T$ (in fact, its Lie algebra $\mathfrak {h}$ is given by the centralizer $Z_\mathfrak{g}(\mathfrak{t})$ in $\mathfrak g$ of the Lie algebra $\mathfrak {t}$ of $T$). We will see that actually $H=T$ showing that $H$ is compact.
Indeed, it is well known that any element of $K$ conjugates into $T$, and therefore $$\bigcup_{g\in G}gKg^{-1}=\bigcup_{g\in G}gTg^{-1}.$$
We denote this subset of $G$ by $E$ (it corresponds to the subset of elliptic elements of $G$). Recall that the subset $\mathrm{reg}(G)$ of regular elements in $G$ is open and dense. By assumption, $E$ has nonempty interior, so there exists a nonempty open subset $V$ of $G$ such that $V\subset \mathrm{reg}(G)\cap E$. Up to conjugating $V$, we can assume $V\cap T\neq \emptyset$ and thus $V\cap H\neq \emptyset$. Let $x\in V\cap H$. Then $x\in gTg^{-1}$ for some $g\in G$. Hence, $x\in gHg^{-1}$ as well, and, since $x$ is a regular element of $G$, it belongs to unique Cartan subgroup of $G$. We conclude that $H=gHg^{-1}$, and thus also $T=gTg^{-1}$ because $T$ is maximal compact and $H$ is nilpotent. This means that $x$ belongs to $T$ and thus $V\cap H\subset T$. From here, it is not hard to see that $H=T$ must hold, proving that $H$ is compact.