Is a rational function which maps all circles/lines to circles/lines a Möbius transformation? It is well-known that Möbius transformations map circles and lines to circles and lines. (Here and in the following, “line” means a line in the extended complex plane $\hat{\Bbb C}$, including the point at infinity.)
My question is if that property characterizes Möbius transformations, i.e. if the following converse statement is true:

Let $f$ be a rational function which maps circles and lines to circles and lines. Then $f$ is a Möbius transformation.

Just to be clear: The property is that if $C$ is a circle or a line then $f(C)$ is also a circle or a line. If we consider $f$ as a mapping of the Riemann sphere onto itself then it means that circles on the sphere are mapped to circles.
Context
In a now deleted question the following was asked:

Suppose $f$ is a continuous function on the extended complex plane which is analytic except possibly at one point and maps lines and circles to lines and circles. Does it follow that $f$ is necessarily a Möbius transformation?

It is not difficult to see that under those conditions, $f$ has a removable singularity at the possible exception point, so that it is analytic in all of the extended complex plane, and therefore a rational function. That leads to the above question.
This is posted as a self-answered question because I figured out a solution which seems not to be posted before. Of course other answers are most welcome.
A previous related questions is Is a function that maps circles to circles necessarily a Möbius transformation?
 where the following examples are given:

*

*a finite Blaschke product maps the unit circle onto itself.

*The functions $z \mapsto z^p$ map all lines through the origin to lines, and all circles with center at the origin to circles.

That are not counterexamples to the above conjecture because not all circles and lines are mapped to circles and lines.
 A: Yes, the conjecture is true. A rational function which maps circles and lines to circles and lines is necessarily a Möbius transformation.
For the proof we can without loss of generality assume that $f(\infty) = \infty$ and that $f$ has a simple zero at $z=0$. (Otherwise consider $\tilde f = T \circ f \circ S$ with suitably chosen Möbius transformations $T$ and $S$.) Then every line through the origin is mapped to another line through the origin.
Choose two lines $l_1, l_2$ through the origin and let $L_1, L_2$ be the corresponding images. The angle between $L_1$ and $L_2$ is the same as the angle between $l_1$ and $l_2$ (here we use that $f$ has a simple zero, so that it preserves angles locally). Let us denote that angle between the lines with $\alpha$.
If we denote the reflection at the lines $l_1, l_2, L_1, L_2$ with $r_1, r_2, R_1, R_2$ respectively, then the Schwarz reflection principle tells us that
$$
  f \circ r_j = R_j \circ f \, , \, j=1, 2 
$$
and therefore
$$
 f \circ r_1 \circ r_2 = R_1 \circ R_2 \circ f \, .
$$
But the composition of reflections at intersecting lines is a rotation, and it follows  that
$$
 f(e^{i2\alpha} z) = e^{i2\alpha} f(z) \, .
$$
This holds for all $z$ and all real $\alpha$. Substituting this in the power series $f(z) = \sum_{n=1}^\infty a_n z^n$ at the origin gives
$$
 a_n (e^{i2n\alpha} - e^{i2\alpha}) = 0
$$
for all $n \ge 1$. If we choose $\alpha$ such that $e^{i2\alpha}$ is not a root of unity then $a_n = 0$ for $n \ge 2$ follows.
We have therefore shown that $f$ (after some composition with Möbius transformation) is a linear function, and that concludes the proof.
A: $f$ is necessarily injective - let us use the same setup you have provided, namely assume that $f(\infty)=\infty$ and $f(0)$ is a simple zero. We now take $z_1,z_2\in f^{-1}(w)$ and form great circles $L_1,L_2$ that pass through $0,z_1,\infty$ and $0,z_2,\infty$ resp. Clearly $f(L_1),f(L_2)$ are the same great circles that pass through $0,w,\infty$, however that contradicts angle preservation at $0$. Thus $f$ has at worst a simple pole and a simple zero, for otherwise injectivity of $f$ and $1/f$ would be violated. The rest is clear.
A: HINT:
Consider $f$ is holomorphic around $z=0$, with $z=0$ zero of order $k> 1$. Consider two small circles passing through $z_0 =0$ and another point $z_1$, and forming a small angle $\alpha$. Then their images have angle $k \alpha$ at $f(z_0) =0$, but angle $\alpha$ at $f(z_1)$, so they cannot be circles.
