Magnetic fields are widely observed in various astronomical contexts, yet much remains unknown about their significance across different systems and cosmic epochs. Our current knowledge of the evolution of magnetic fields is limited by scarce observations in the distant Universe, where galaxies have recently been found to be more evolved than most model predictions. To address this gap, we conducted rest-frame 131\,mu m full-polarisation observations of dust emission in a strongly lensed dusty star-forming galaxy, SPT0346$-$52, at $z=5.6$, when the Universe was only 1 Gyr old. Dust grains can become aligned with local magnetic fields, resulting in the emission of linearly polarised thermal infrared radiation. Our observations have revealed a median polarisation level of $0.9 percent with a variation of $ percent across the 3\,kiloparsecs extention, indicating the presence of large-scale ordered magnetic fields. The polarised dust emission is patchy, offset from the total dust emission and mostly overlaps with the C\ ii $. The bimodal distribution of field orientations, their spatial distribution, and the connection with the cold gas kinematics further emphasise the complexity of the magnetic environment in this galaxy and the potential role of mergers in shaping its magnetic fields. Such early formation of ordered galactic magnetic fields also suggests that both small-scale and large-scale dynamos could be efficient in early galaxies. Continued observations of magnetic fields in early galaxies, as well as expanding surveys to a wider galaxy population, are essential for a comprehensive understanding of the prevalence and impact of magnetic fields in the evolving Universe.