Working antisocial hours can prematurely age the brain and dull intellectual ability, scientists warn.
Their study, in the journal Occupational and Environmental Medicine, suggested a decade of shifts aged the brain by more than six years.
There was some recovery after people stopped working antisocial shifts, but it took five years to return to normal.
Experts say the findings could be important in dementia, as many patients have disrupted sleep.
The body's internal clock is designed for us to be active in the day and asleep at night.
The damaging effects on the body of working against the body clock, from breast cancer to obesity, are well known.
Now a team at the University of Swansea and the University of Toulouse has shown an impact on the mind as well.
Three thousand people in France performed tests of memory, speed of thought and wider cognitive ability.
The brain naturally declines as we age, but the researchers said working antisocial shifts accelerated the process.
Those with more than 10 years of shift work under their belts had the same results as someone six and a half years older.
The good news is that when people in the study quit shift work, their brains did recover. Even if it took five years.
Dr Philip Tucker, part of the research team in Swansea, told the BBC: "It was quite a substantial decline in brain function, it is likely that when people trying to undertake complex cognitive tasks then they might make more mistakes and slip-ups, maybe one in 100 makes a mistake with a very large consequence, but it's hard to say how big a difference it would make in day-to-day life."
He said he would not do night shifts "if I could possibly help it" but they were a "necessary evil" that society could not do without.
"There are ways to mitigate the effects in the way you design work schedules and regular medical check-ups... should include cognitive performance tests to look for danger signs," he added.
Dr Michael Hastings, from the UK Medical Research Council's Laboratory of Molecular Biology, told the BBC: "The reversibility is a really exciting finding because no-one else has shown it and no matter how compromised a person may be there's always hope of recovery."
He said the findings may have important consequences in dementia, which is known to damage sleeping patterns in a similar way to shift work.
"If you can keep the sleep-wake cycle as solid as possible you're unlikely to reverse neurodegeneration, but you can ameliorate one of the consequences.
"In nursing homes one thing you can do to help is to set a very clear daily routine to encourage a sensible 24-hour pattern of activity, it needs bright lights in the day, resting at night and appropriate medication such as melatonin before bed.
Prof Derk-Jan Dijk, from the Surrey Sleep Centre, cautioned that retired shift workers still had lower sleep quality than people who had never done nights.
"So some of these effects may not be so readily or rapidly reversed."
He added: "We now accept that shift work may not be good for your physical health, but this shows your brain function is affected, and I think that finding will surprise many people."