Suppose I have two coordinates on the same (subset of a) Riemannian manifold. If the metric tensor is analytic in both coordinates, is the change of variables between them necessarily analytic?

In other (and perhaps clearer) words, is this conjecture true?

Let $U,V\subset\mathbb R^n$ be domains. Let $g$ be a real-analytic Riemannian metric on $U$ and let $\phi\colon V\to U$ be a smooth diffeomorphism. If $\phi^*g$ is a real-analytic metric on $V$, then $\phi$ is real analytic.

I have not been able to prove this or find a counterexample.

The difficulty in using the formula for the metric pulled back over $\phi$, $$ \phi^*g_{ij}(x) = \partial_i\phi^k(x)g_{kl}(\phi(x))\partial_j\phi^l(x), $$ is that $\phi$ appears several times and in different ways in the right-hand side. Taking determinants yields $\det(\phi^*g(x))=\det(g(\phi(x)))\det(D\phi(x))^2$, which might help if one could change coordinates analytically on $U$ so that $\det(g(y))$ is constant and show that analyticity of $\det(D\phi)$ implies analyticity of $\phi$. (Compare this with the one-dimensional proof below.)

The claim is true if $n=1$, but I do not see how to generalize this argument: A Riemannian metric on $\mathbb R$ is just a positive scalar function. After a real-analytic change of coordinates on $U$ one can assume that $g\equiv1$ (Euclidean metric). Then $\phi^*g(x)=\phi'(x)^2$. Since this is analytic and $\phi'$ never vanishes, the function $\phi$ is analytic.