4. As shown in the figure, given the ellipse $E: \frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}=1(a>b>0)$, the circle $O: x^{2}+y^{2}=a^{2}$ intersects the positive half-axis of the $y$-axis at point $B$. A line passing through point $B$ is tangent to the ellipse $E$ and intersects the circle $O$ at another point $A$. If $\angle A O B=60^{\circ}$, then the eccentricity of the ellipse $E$ is
A. $\frac{1}{2}$
B. $\frac{1}{3}$
C. $\frac{\sqrt{2}}{2}$
D. $\frac{\sqrt{3}}{3}$
Given $A\left(\frac{\sqrt{3} a}{2}, \frac{a}{2}\right) \Rightarrow k_{A B}=-\frac{\sqrt{3}}{3}$, substituting the line $A B: y=-\frac{\sqrt{3}}{3} x+a$ into the coarse circle equation yields
$$
\begin{array}{l}
\left(\frac{1}{a^{2}}+\frac{1}{3 b^{2}}\right) x^{2}-\frac{2 \sqrt{3} a}{3 b^{2}} x+\frac{a^{2}}{b^{2}}-1=0 \Rightarrow \Delta=\frac{4 a^{2}}{3 b^{4}}-4\left(\frac{1}{a^{2}}+\frac{1}{3 b^{2}}\right)\left(\frac{a^{2}}{b^{2}}-1\right)=0 \\
\Rightarrow \frac{a^{2}}{3}=\left(\frac{b^{2}}{a^{2}}+\frac{1}{3}\right)\left(a^{2}-b^{2}\right) \Rightarrow \frac{1}{3}=\left(\frac{b^{2}}{a^{2}}+\frac{1}{3}\right)\left(1-\frac{b^{2}}{a^{2}}\right)=e^{2}\left(\frac{4}{3}-e^{2}\right) \\
\Rightarrow 3 e^{4}-4 e^{2}+1=0 \Rightarrow e^{2}=\frac{1}{3} \Rightarrow e=\frac{\sqrt{3}}{3}, \text { so choose } D .
\end{array}
$$