When a newborn baby appears to smile for the first time it is perhaps one of the most rewarding experiences a new parent has.

Of course, the baby is probably not smiling in response to a social trigger. An apparent "smile" in the earliest days might simply be an unintentional change in facial expressions.

In 1959 a researcher called Peter Wolff called these "spontaneous neonatal smiles". They involve, he wrote, a "slow, gentle, sideward, and upward pull of the mouth, without rhythmical mouthing movements or contraction of other facial muscles".

In fact, this type of spontaneous smile often happens during sleep. However, the cause of these neonatal smiles is unclear.

We now know that humans are not alone in this seemingly innate reaction. A decade ago it was discovered that chimpanzee babies show similar spontaneous smiles.

When I observed this smiling in an infant macaque, I simply thought 'oh this is the same as humans'

Chimps are one of our closest living relatives in the animal kingdom today. As we share a common ancestor with them, which lived between six and 13 million years ago, the finding suggests that smiling goes back to at least that far.

A team led by Fumito Kawakami of Kyoto University's Primate Research Institute in Japan, has now discovered that spontaneous smiles go back even further.

"Infant Japanese macaques are super-cute and their facial configuration is almost the same as humans," says Kawakami. "So when I observed this smiling in an infant macaque, I simply thought 'oh this is the same as humans'."

After noticing some smiles while performing health checks on the macaques, he wanted to uncover whether it was more common.

We can infer that the origin of smiling goes back to around 30 million years

To do so, his team monitored seven newborn Japanese macaques. They all showed spontaneous smiles at least once, within an hour of observation. In all cases they were in a state of REM (rapid eye movement) sleep.

The monkeys ranged in age between four and 21 days old. In all, they produced a total of 58 spontaneous smiles.

This suggests that these smiles are not rare, the researchers say.

"If we can observe the same behavior in more distant relatives [such as] Japanese macaques, we can infer that the origin of smiling goes back to around 30 million years," Kawakami says. In turn, this can help us to understand more about spontaneous smiling in humans.

Kawakami and colleagues have published their observations in the journal Primates.

There are case reports about mice laughing when they get tickled and dogs displaying facial expressions of pleasure

This research shows that the first developmental stage of smiling is shared by humans, apes and monkeys. "After that, only humans use those facial expressions in various contexts," says Kawakami.

The finding also implies that smiling is innate, which would make sense as it is so fundamental to our social world.

Japanese macaques are only the third species observed producing these neonatal smiles. But that does not mean the smiles are unique to these species: it may simply be that nobody has yet noticed other species producing them.

"There are case reports about mice laughing when they get tickled and dogs displaying facial expressions of pleasure," says co-author Masaki Tomonaga. "It may be the case that many mammal infants display spontaneous smiles, in which case smiling would have an older evolutionary origin."

Melissa Hogenboom is BBC Earth's feature writer. She is @melissasuzanneh on Twitter.

Join over five million BBC Earth fans by liking us on Facebook, or follow us on Twitter and Instagram.

If you liked this story, sign up for the weekly bbc.com features newsletter called "If You Only Read 6 Things This Week". A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.