I know that the components of the gradient should transform covariantly, and have used this many times in special relativity, etc. However, I also know that covariant components transform like the coordinate axes, while contravariant components transform in an inverse way, and today, while thinking geometrically about a simple example, I could not get these two statements to agree. So I must be forgetting or misunderstanding something.
Consider a coordinate system $S$ in the plane, with orthonormal basis vectors $\mathbf e_1$, $\mathbf e_2$. Let $S'$ be a different coordinate system, with basis vectors $\mathbf e'_1$, $\mathbf e'_2$ obtained from $S$ by rotating $\mathbf e_1$, $\mathbf e_2$ counterclockwise by an angle $\theta$. That is, $$[\mathbf e'_i]_S = R_\theta [\mathbf e_i]_S, \quad i = 1, 2, \tag{1}$$ where $[\dotsc]_S$ denotes representation in the system $S$, and $$R_\theta = \begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}. \tag{2}$$ Position vectors, being contravariant (under rotations), transform in the inverse manner $$\mathbf r' = R_\theta^{-1} \mathbf r = R_{-\theta} \mathbf r \quad \Leftrightarrow \quad \mathbf r = R_\theta \mathbf r'.\tag{3}$$ So far so good. But now consider the gradient of a scalar field $\phi$. I get, by the chain rule (and with implicit summation over repeated indices), $$(\nabla \phi)'_i = \frac{\partial \phi}{\partial x'^i} = \frac{\partial \phi}{\partial x^j} \frac{\partial x^j}{\partial x'^i} = (\nabla \phi)_j(R_\theta)_{ji} = (\nabla \phi)_j(R^{-1}_\theta)_{ij} = (R^{-1}_\theta \nabla \phi)_i, \tag{4} $$ so that $(\nabla \phi)' = R^{-1}_\theta \nabla \phi = R_{-\theta} \nabla \phi$, indicating that the components of the gradient transform like the position vectors! But this cannot be right, since one is supposed to transform covariantly and the other contravariantly.