Researchers at Durham University said the process was "adaptive" and helped the unborn baby to prepare for life after birth.
The study expands on previous research that suggests that facial expressions of healthy foetuses develop and become more complex during pregnancy.
– Lead researcher Dr Nadja Reissland, Durham University, Department of Psychology
"It is vital for infants to be able to show pain as soon as they are born so that they can communicate any distress or pain they might feel to their carers and our results show that healthy foetuses 'learn' to combine the necessary facial movements before they are born.
"This suggests that we can determine the normal development of facial movements and potentially identify abnormal development too.
"This could then provide a further medical indication of the health of the unborn baby."
Unborn babies "practise" facial expressions of pain while they are in the womb, scientists from Durham University say.
Foetuses have been pictured using 4D scanning technology showing what appears to be pain.
Researchers suggest the ability to grimace is a "developmental process" which could help doctors asess the health of the foetus.
The study, published in the journal "Plos One", found when the mother was 24 weeks pregnant, unborn babies were able to make simple expressions such as smiling.