Far-infrared and optical [O iii] lines are useful temperature–density diagnostics of nebular as well as dust obscured astrophysical sources. Fine-structure transitions among the ground state levels 1 s22 s22 p33 P 0,1,2 give rise to the 52- and 88-m lines, whereas transitions among the 3 P 0,1,2, 1 D 2, 1 S 0 levels yield the well-known optical lines λλ4363, 4959 and 5007 Å. These lines are excited primarily by electron impact excitation. However, despite their importance in nebular diagnostics collision strengths for the associated fine-structure transitions have not been computed taking full account of relativistic effects. We present Breit–Pauli R-matrix calculations for the collision strengths with highly resolved resonance structures. We find significant differences of up to 20 per cent in the Maxwellian averaged rate coefficients from previous works. We also tabulate these to lower temperatures down to 100 K to enable determination of physical conditions in cold dusty environments such photodissociation regions and ultraluminous infrared galaxies observed with the Herschel Space Observatory. We also examine the effect of improved collision strengths on temperature- and density-sensitive line ratios.