We demonstrate significant cooling of electrons in a nanostructure below 10 mK by demagnetisation of thin-film copper on a silicon chip. Our approach overcomes the typical bottleneck of weak electron-phonon scattering by coupling the electrons directly to a bath of refrigerated nuclei, rather than cooling via phonons in the host lattice. Consequently, weak electron-phonon scattering becomes an advantage. It allows the electrons to be cooled for an experimentally useful period of time to temperatures colder than the dilution refrigerator platform, the incoming electrical connections, and the host lattice. There are efforts worldwide to reach sub-millikelvin electron temperatures in nanostructures to study coherent electronic phenomena and improve the operation of nanoelectronic devices. On-chip magnetic cooling is a promising approach to meet this challenge. The method can be used to reach low, local electron temperatures in other nanostructures, obviating the need to adapt traditional, large demagnetisation stages. We demonstrate the technique by applying it to a nanoelectronic primary thermometer that measures its internal electron temperature. Using an optimised demagnetisation process, we demonstrate cooling of the on-chip electrons from 9 mK to below 5 mK for over 1000 seconds.