  We present optical and near-infrared observations of the afterglow of the
gamma-ray burst GRB 050904. We derive a photometric redshift z = 6.3, estimated
from the presence of the Lyman break falling between the I and J filters. This
is by far the most distant GRB known to date. Its isotropic-equivalent energy
is 3.4x10^53 erg in the rest-frame 110-1100 keV energy band. Despite the high
redshift, both the prompt and the afterglow emission are not peculiar with
respect to other GRBs. We find a break in the J-band light curve at t_b = 2.6
+- 1.0 d (observer frame). If we assume this is the jet break, we derive a
beaming-corrected energy E_gamma = (4-12)x10^51 erg. This limit shows that GRB
050904 is consistent with the Amati and Ghirlanda relations. This detection is
consistent with the expected number of GRBs at z > 6 and shows that GRBs are a
powerful tool to study the star formation history up to very high redshift.
