The nature of the jets and the role of magnetic fields in gamma-ray bursts (GRB) remains unclear 1, 2 . In a baryon-dominated jet only weak, tangled fields generated in situ through shocks would be present 3 . In an alternative model, jets are threaded with large scale magnetic fields that originate at the central engine and which accelerate and collimate the jets 4 . The way to distinguish between the models is to measure the degree of polarization in early-time emission, however previous claims of γ-ray polarization have been controversial 5-8 . Here we report that the early optical emission from GRB 090102 was polarized at the level of P = 10 ± 1%, indicating the presence of large-scale fields originating in the expanding fireball. If the degree of polarization and its position angle were variable on timescales shorter than our 60-s exposure, then the peak polarization may have been larger than 10 per cent.The standard GRB fireball model 3 comprises an initial compact emitting region, expanding relativistically, in which internal shocks dissipate the bulk energy, converting kinetic to radiated energy, the so-called prompt emission. As the shell of the relativistically expanding fireball collides with the surrounding circumburst medium, a forward shock is produced, which propagates outwards through the external medium and results in the long-lived afterglow whose emission is detectable from X-ray to optical, infrared and, in some cases, radio wavelengths. Interaction of 1