  In this article we study any 4-dimensional Riemannian manifold $(M,g)$ with
harmonic curvature which admits a smooth nonzero solution $f$ to the following
equation \begin{eqnarray} \label{0002bx} \nabla df = f(Rc -\frac{R}{n-1} g) + x
Rc+ y(R) g. \end{eqnarray} where $Rc$ is the Ricci tensor of $g$, $x$ is a
constant and $y(R)$ a function of the scalar curvature $R$. We show that a
neighborhood of any point in some open dense subset of $M$ is locally isometric
to one of the following five types; {\rm (i)} $ \mathbb{S}^2(\frac{R}{6})
\times \mathbb{S}^2(\frac{R}{3})$ with $R>0$, {\rm (ii)} $
\mathbb{H}^2(\frac{R}{6}) \times \mathbb{H}^2(\frac{R}{3}) $ with $R<0$, where
$\mathbb{S}^2(k) $ and $\mathbb{H}^2(k) $ are the two-dimensional Riemannian
manifold with constant sectional curvature $k>0$ and $k<0$, respectively, {\rm
(iii)} the static spaces in Example 3 below, {\rm (iv)} conformally flat static
spaces described in Kobayashi's \cite{Ko}, and {\rm (v)} a Ricci flat metric.
  We then get a number of Corollaries, including the classification of the
following four dimensional spaces with harmonic curvature; static spaces,
Miao-Tam critical metrics and $V$-static spaces.
  The proof is based on the argument from a preceding study of gradient Ricci
solitons \cite{Ki}. Some Codazzi-tensor properties of Ricci tensor, which come
from the harmonicity of curvature, are effectively used.
