  Iteration of a rational function $R$ gives a complex dynamical system on the
Riemann sphere. We introduce a $C^*$-algebra ${\mathcal O}_R$ associated with
$R$ as a Cuntz-Pimsner algebra of a Hilbert bimodule over the algebra $A =
C(J_R)$ of continuous functions on the Julia set $J_R$ of $R$. The algebra
${\mathcal O}_R$ is a certain analog of the crossed product by a boundary
action. We show that if the degree of $R$ is at least two, then $C^*$-algebra
${\mathcal O}_R$ is simple and purely infinite. For example if $R(z) = z^2 -
2$, then the Julia set $J_R = [-2,2]$ and the restriction $R : J_R \to J_R$ is
topologically conjugate to the tent map on $[0,1]$. The algebra ${\mathcal
O}_{z^2 - 2}$ is isomorphic to the Cuntz algebra ${\mathcal O}_{\infty}$. We
also show that the Lyubich measure associated with $R$ gives a unique KMS state
on the $C^*$-algebra ${\mathcal O}_R$ for the gauge action at inverse
temperature $\log (\deg R)$ if the Julia set contains no critical points.
