We present a power-spectrum analysis of the final 2dF Galaxy Redshift Survey (2dFGRS), employing a direct Fourier method. The sample used comprises 221 414 galaxies with measured redshifts. We investigate in detail the modelling of the sample selection, improving on previous treatments in a number of respects. A new angular mask is derived, based on revisions to the photometric calibration. The redshift selection function is determined by dividing the survey according to rest-frame colour, and deducing a self-consistent treatment of k-corrections and evolution for each population. The covariance matrix for the power-spectrum estimates is determined using two different approaches to the construction of mock surveys, which are used to demonstrate that the input cosmological model can be correctly recovered. We discuss in detail the possible differences between the galaxy and mass power spectra, and treat these using simulations, analytic models and a hybrid empirical approach. Based on these investigations, we are confident that the 2dFGRS power spectrum can be used to infer the matter content of the universe. On large scales, our estimated power spectrum shows evidence for the ‘baryon oscillations’ that are predicted in cold dark matter (CDM) models. Fitting to a CDM model, assuming a primordial ns= 1 spectrum, h= 0.72 and negligible neutrino mass, the preferred parameters are Ωmh= 0.168 ± 0.016 and a baryon fraction Ωb/Ωm= 0.185 ± 0.046 (1σ errors). The value of Ωmh is 1σ lower than the 0.20 ± 0.03 in our 2001 analysis of the partially complete 2dFGRS. This shift is largely due to the signal from the newly sampled regions of space, rather than the refinements in the treatment of observational selection. This analysis therefore implies a density significantly below the standard Ωm= 0.3: in combination with cosmic microwave background (CMB) data from the Wilkinson Microwave Anisotropy Probe (WMAP), we infer Ωm= 0.231 ± 0.021.