4. As shown in Figure 1, in the right triangular prism $A B C-A_{1} B_{1} C_{1}$, $A A_{1}=A B=A C$, and $M$ and $Q$ are the midpoints of $C C_{1}$ and $B C$ respectively. If for any point $P$ on the line segment $A_{1} B_{1}$, $P Q \perp A M$, then $\angle B A C$ equals ( ).
(A) $30^{\circ}$
(B) $45^{\circ}$
(C) $60^{\circ}$
(D) $90^{\circ}$
4.D.

Let the midpoint of $A C$ be $R$. It is easy to know that $A_{1} R \perp A M$. Also, $P Q \perp A M$, so $A M \perp$ plane $A_{1} B_{1} Q R$. Therefore, $A M \perp Q R$, which means $A M \perp A B$. Also, $A B \perp A A_{1}$, so $A B \perp$ plane $A C C_{1} A_{1}$. Therefore, $A B \perp A C$.