4. Given that $a$ and $b$ are non-zero and non-collinear vectors, let condition $M: b \perp (a-b)$;
condition $N$: for all $x \in \mathbf{R}$, the inequality $|a-x b|$ $\geqslant |a-b|$ always holds.
Then $M$ is ( ) of $N$.
(A) necessary but not sufficient condition
(B) sufficient but not necessary condition
(C) sufficient and necessary condition
(D) neither sufficient nor necessary condition
4.C.

As shown in Figure 2, let $O A=a$, $O B=b$, then $x b$ represents any vector collinear with $O B$, $|a-x b|$ represents the distance $A C$ from point $A$ to any point $C$ on the line $O B$, and $|a-b|$ represents the distance from point $A$ to $B$.
When $b \perp(a-b)$, $A B \perp O B$.
By the shortest distance from a point to a line being the perpendicular distance, $A C \geqslant A B$, i.e., for all $x \in R$, the inequality $|a-x b| \geqslant|a-b|$ always holds.
Conversely, if $A C \geqslant A B$ always holds, then $A C_{\text {min }} \geqslant A B$. Therefore, $A B$ must be