[proofplan]
The proof is a direct unwinding of the two definitions. The adjoint operator $\operatorname{ad}_x$ acts on an element $i \in I$ by taking the Lie bracket $[x,i]$. Thus the ideal condition $[\mathfrak g,I] \subset I$ is exactly the condition that each $\operatorname{ad}_x$ maps $I$ into itself. Skew-symmetry of the Lie bracket also shows that the equivalent condition $[I,\mathfrak g] \subset I$ gives the same subspace.
[/proofplan]
[step:Translate the ideal condition into adjoint invariance]
Assume first that $I$ is an ideal of $\mathfrak g$. By definition, this means that
\begin{align*}
[x,i] \in I
\end{align*}
for every $x \in \mathfrak g$ and every $i \in I$.
Fix $x \in \mathfrak g$. The adjoint operator associated to $x$ is the $k$-[linear map](/page/Linear%20Map)
\begin{align*}
\operatorname{ad}_x: \mathfrak g &\to \mathfrak g \\
y &\mapsto [x,y].
\end{align*}
For every $i \in I$, the ideal condition gives
\begin{align*}
\operatorname{ad}_x(i) = [x,i] \in I.
\end{align*}
Therefore $\operatorname{ad}_x(I) \subset I$. Since $x \in \mathfrak g$ was arbitrary, $I$ is invariant under every operator $\operatorname{ad}_x$.
[guided]
Assume that $I$ is an ideal of $\mathfrak g$. The definition of an ideal in a Lie algebra says that bracketing an element of $I$ with an arbitrary element of $\mathfrak g$ keeps the result inside $I$. In the convention used here, this is the condition
\begin{align*}
[x,i] \in I
\end{align*}
for every $x \in \mathfrak g$ and every $i \in I$.
Now fix an arbitrary element $x \in \mathfrak g$. The adjoint operator determined by $x$ is the map
\begin{align*}
\operatorname{ad}_x: \mathfrak g &\to \mathfrak g \\
y &\mapsto [x,y].
\end{align*}
To prove that $I$ is invariant under $\operatorname{ad}_x$, we must prove that every element of $I$ is sent back into $I$. Let $i \in I$. By the definition of $\operatorname{ad}_x$,
\begin{align*}
\operatorname{ad}_x(i) = [x,i].
\end{align*}
Since $I$ is an ideal, the right-hand side lies in $I$. Hence $\operatorname{ad}_x(i) \in I$ for every $i \in I$, which is exactly
\begin{align*}
\operatorname{ad}_x(I) \subset I.
\end{align*}
Because the element $x \in \mathfrak g$ was arbitrary, this holds for every adjoint operator $\operatorname{ad}_x$.
[/guided]
[/step]
[step:Translate adjoint invariance back into the ideal condition]
Conversely, assume that
\begin{align*}
\operatorname{ad}_x(I) \subset I
\end{align*}
for every $x \in \mathfrak g$. Let $x \in \mathfrak g$ and $i \in I$. Since $i \in I$ and $I$ is invariant under $\operatorname{ad}_x$, we have
\begin{align*}
[x,i] = \operatorname{ad}_x(i) \in I.
\end{align*}
Thus $[\mathfrak g,I] \subset I$, so $I$ is an ideal of $\mathfrak g$.
[guided]
Assume now that $I$ is invariant under every adjoint operator. This means that for each fixed $x \in \mathfrak g$, the map
\begin{align*}
\operatorname{ad}_x: \mathfrak g &\to \mathfrak g \\
y &\mapsto [x,y]
\end{align*}
satisfies
\begin{align*}
\operatorname{ad}_x(I) \subset I.
\end{align*}
To prove that $I$ is an ideal, we must show that bracketing an arbitrary element of $\mathfrak g$ with an arbitrary element of $I$ gives an element of $I$. Let $x \in \mathfrak g$ and let $i \in I$. Since $I$ is invariant under $\operatorname{ad}_x$, applying $\operatorname{ad}_x$ to the element $i \in I$ gives an element of $I$. Using the definition of $\operatorname{ad}_x$, this says
\begin{align*}
[x,i] = \operatorname{ad}_x(i) \in I.
\end{align*}
Because this holds for every $x \in \mathfrak g$ and every $i \in I$, we have
\begin{align*}
[\mathfrak g,I] \subset I.
\end{align*}
That is precisely the ideal condition for $I$.
[/guided]
[/step]
[step:Record the equivalent right-bracket formulation]
For completeness, the condition $[\mathfrak g,I] \subset I$ is equivalent to $[I,\mathfrak g] \subset I$. Indeed, if $x \in \mathfrak g$ and $i \in I$, skew-symmetry of the Lie bracket gives
\begin{align*}
[i,x] = -[x,i].
\end{align*}
Since $I$ is a $k$-linear subspace, $[x,i] \in I$ if and only if $-[x,i] \in I$. Hence the left-bracket and right-bracket formulations of the ideal condition agree. Combining the two previous steps proves the desired equivalence.
[/step]