The one-loop effective action for a generic set of quantum fields is calculated as a nonlocal expansion in powers of the curvatures (field strengths). This expansion is obtained to third order in the curvature. It is stressed that the covariant vertices are finite. The trace anomaly in four dimensions is obtained directly by varying the effective action. The nonlocal terms in the action, producing the anomaly, contain nontrivial functions of three operator arguments. The trace anomaly is derived also by making the conformal transformation in the heat kernel.