The study of the properties of galaxies in the first billion years after the Big Bang is one of the major topics of current astrophysics. Optical and near-infrared spectroscopy of the afterglows of long gamma-ray bursts (GRBs) provides a powerful diagnostic tool to probe the interstellar medium (ISM) of their host galaxies and foreground absorbers, even up to the highest redshifts. We analyze the VLT/X-shooter afterglow spectrum of GRB 210905A, triggered by the Neil Gehrels Swift Observatory, and detect neutral hydrogen, low-ionization, high-ionization, and fine-structure absorption lines from a complex system at z = 6.3118, which we associate with the GRB host galaxy. We use them to study the ISM properties of the host system, revealing the metallicity, kinematics, and chemical abundance pattern of its gas along the GRB line of sight. We also detect absorption lines from at least two foreground absorbers at z = 5.7390 and z = 2.8296. The total metallicity of the z ∼ 6.3 system is [M/H]tot = −1.72 ± 0.13, after correcting for dust depletion and taking α-element enhancement into account, as suggested by our analysis. This is consistent with the values found for the other two GRBs at z ∼ 6 with spectroscopic data showing metal absorption lines (GRB 050904 and GRB 130606A), and it is at the higher end of the metallicity distribution of quasar damped Lyman-α systems (QSO-DLAs) extrapolated to such a high redshift. In addition, we determine the overall amount of dust and dust-to-metal mass ratio (DTM) ([Zn/Fe]fit = 0.33 ± 0.09 and DTM = 0.18 ± 0.03). We find indications of nucleosynthesis due to massive stars and, for some of the components of the gas clouds, we find evidence of peculiar nucleosynthesis, with an overabundance of aluminum (as also found for GRB 130606A). From the analysis of fine-structure lines, we determine distances of several kiloparsecs for the low-ionization gas clouds closest to the GRB. Those are farther distances than usually found for GRB host absorption systems, possibly due to the very high number of ionizing photons produced by the GRB that could ionize the line of sight up to several hundreds of parsecs. Using the HST/F140W image of the GRB field, we show the GRB host galaxy (with a possible afterglow contamination) as well as multiple objects within 2″ from the GRB position. We discuss the galaxy structure and kinematics that could explain our observations, also taking into account a tentative detection of Lyman-α emission at z = 6.3449 (∼1200 km s−1 from the GRB redshift in velocity space), and the observational properties of Lyman-α emitters at very high redshift. This study shows the amazing potential of GRBs to access detailed information on the properties (metal enrichment, gas kinematic, dust content, nucleosynthesis...) of very high-redshift galaxies, independently of the galaxy luminosity. Deep spectroscopic observations with VLT/MUSE and JWST will offer the unique possibility of combining the information presented in this paper with the properties of the ionized gas, with the goal of better understanding how galaxies in the reionization era form and evolve.