4. As shown in Figure 1,

Ellipse $E: \frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}$ $=1(a>b>0)$, - $O: x^{2}+y^{2}=a^{2}$ intersects the positive $y$-axis at point $B$, a line passing through point $B$ is tangent to ellipse $E$, and intersects circle $\odot O$ at another point $A$. If $\angle A O B=60^{\circ}$, then the eccentricity of ellipse $E$ is ( ).
(A) $\frac{1}{2}$
(B) $\frac{1}{3}$
(C) $\frac{\sqrt{2}}{2}$
(D) $\frac{\sqrt{3}}{3}$
4. D.

Since $|O A|=|O B|, \angle A O B=60^{\circ}$, therefore, $\triangle A O B$ is an equilateral triangle.
Thus, the slope of $l_{A B}$ is $\pm \frac{\sqrt{3}}{3}$.
Hence, $l_{A B}: y= \pm \frac{\sqrt{3}}{3} x+a$.
Substituting into the ellipse equation, we get
$$
\begin{array}{l}
\left(a^{2}+3 b^{2}\right) x^{2} \pm 2 \sqrt{3} a^{3} x+3 a^{2}\left(a^{2}-b^{2}\right)=0 . \\
\text { By } \Delta=12 a^{6}+12 a^{2}\left(a^{2}+3 b^{2}\right)\left(a^{2}-b^{2}\right)=0 \\
\Rightarrow 2 a^{2}=3 b^{2} \Rightarrow 2 a^{2}=3\left(a^{2}-c^{2}\right) \\
\Rightarrow a^{2}=3 c^{2} \Rightarrow e=\frac{c}{a}=\frac{\sqrt{3}}{3} .
\end{array}
$$