Working memory, the process through which information is transiently maintained and manipulated over a brief period, is essential for most cognitive functions1-4. However, the mechanisms underlying the generation and evolution of working-memory neuronal representations at the population level over long timescales remain unclear. Here, to identify these mechanisms, we trained head-fixed mice to perform an olfactory delayed-association task in which the mice made decisions depending on the sequential identity of two odours separated by a 5 s delay. Optogenetic inhibition of secondary motor neurons during the late-delay and choice epochs strongly impaired the task performance of the mice. Mesoscopic calcium imaging of large neuronal populations of the secondary motor cortex (M2), retrosplenial cortex (RSA) and primary motor cortex (M1) showed that many late-delay-epoch-selective neurons emerged in M2 as the mice learned the task. Working-memory late-delay decoding accuracy substantially improved in the M2, but not in the M1 or RSA, as the mice became experts. During the early expert phase, working-memory representations during the late-delay epoch drifted across days, while the stimulus and choice representations stabilized. In contrast to single-plane layer 2/3 (L2/3) imaging, simultaneous volumetric calcium imaging of up to 73,307 M2 neurons, which included superficial L5 neurons, also revealed stabilization of late-delay working-memory representations with continued practice. Thus, delay- and choice-related activities that are essential for working-memory performance drift during learning and stabilize only after several days of expert performance.