P. Shumyatsky's question 11.126 in the “Kourovka Notebook” is answered in the affirmative: it is proved that there exist a constant $c$ and a function of a positive integer argument $f(m)$ such that if a finite group $G$ admits an automorphism $\varphi$ of order 4 having exactly $m$ fixed points, then $G$ has a normal series $G\geqslant H\geqslant N$ such that $|G/H|\leqslant f(m)$, the quotient group $H/N$ is nilpotent of class $\leqslant 2$, and the subgroup $N$ is nilpotent of class $\leqslant c$ (Thm. 1). As a corollary we show that if a locally finite group $G$ contains an element of order 4 with finite centralizer of order $m$, then $G$ has the same kind of a series as in Theorem 1. Theorem 1 generalizes Kovác's theorem on locally finite groups with a regular automorphism of order 4, whereby such groups are center-by-metabelian. Earlier, the first author proved that a finite 2-group with an almost regular automorphism of order 4 is almost center-by-metabelian. The proof of Theorem 1 is based on the author's previous works dealing in Lie rings with an almost regular automorphism of order 4. Reduction to nilpotent groups is carried out by using Hall-Higman type theorems. The proof also uses Theorem 2, which is of independent interest, stating that if a finite group $S$ contains a nilpotent subgroup $T$ of class $c$ and index $|S:T|=n$, then $S$ contains also a characteristic nilpotent subgroup of class $\leqslant c$ whose index is bounded in terms of $n$ and $c$. Previously, such an assertion has been known for Abelian subgroups, that is, for $c=1$.