(CNN) Turns out, Neanderthals were just like us. When in pain, they self-medicated.

A new study that focused on the hardened dental plaque of four Neanderthals -- two found at a site in Spain and two from Belgium -- indicates they may have turned to plants to relieve pain.

One young Neanderthal in Spain appeared to treat a dental abscess with medicinal plants, highlighting an ability toseek pain relief long before pills came into existence, according to the study.

The study published Wednesday in the journal Nature had several surprises.

For starters, the Neanderthals from Spain had completely different diets from their counterparts found in Belgium.

They chowed on various foods, including mushrooms, pine nuts and sheep meat, depending on the region they lived in.

DNA analysis from tooth plaque reveals insight into Neanderthals' behavior.

Just veggies in Spain

The pair of Neanderthals from El Sidrón Cave in Spain led what appears to have been a vegetarian lifestyle. A study of their dental plaque revealed they dined on mushrooms, moss and pine nuts -- with no meat.

They were not necessarily vegetarians by choice, however. It was more likely a product of their environment.

The Neanderthals in that region lived in dense forests with no animals, according to Alan Cooper, co-author of the study and professor at the University of Adelaide in Australia.

But the more surprising finding was that one of the two Neanderthals from Spain appeared to have used plants to treat his ailments.

This Neanderthal had a nasty tooth abscess, bad diarrhea and appeared to be "self-medicating," Cooper said.

Plaque from his teeth showed he was eating poplar, which contains the active ingredient of aspirin. The plaque also indicated a presence of a natural form of the antibiotic penicillin that was not found in the other specimens, he said.

"Apparently, Neanderthals possessed a good knowledge of medicinal plants and their various anti-inflammatory and pain-relieving properties ...," Cooper said in a statement.

"The use of antibiotics would be very surprising, as this is more than 40,000 years before we developed penicillin."

The findings paint a different image of Neanderthals, who have long been associated with a simple existence. However, Cooper cautioned, this Neanderthal could also have eaten the plants without knowing of their medicinal qualities.

Unlike the Neanderthals from Spain, their counterparts from Spy Cave in Belgium were feasting on more than just vegetables.

"We found that the Neanderthals from Spy Cave consumed woolly rhinoceros and European wild sheep, supplemented with wild mushrooms," Cooper said.

"Those from El Sidrón Cave on the other hand showed no evidence for meat consumption ... showing quite different lifestyles between the two groups."

Performing dentistry on Neanderthals

Before this study, the diet of Neanderthals was hotly debated amongst researchers because different theories arose from studying the wear on Neanderthal teeth.

"Our study really tied together years of previous research from many different fields, as we're able to describe these different diets in different Neanderthals with very high resolution," said Laura Weyrich, lead study author and postdoctoral research associate at the University of Adelaide.

The samples used range from between 42,000 to 50,000 years old, making them the oldest dental plaque to be analyzed genetically, according to Cooper.

Because dental plaque is a biofilm of bacteria that calcifies and hardens, it can preserve bacteria for thousands of years, Weyrich said.

"In ancient dental calculus, we are able to find DNA from the microorganisms in the plaque, but also anything else that has gone into the mouth, including food or work items -- for example if ancient people were cutting rope with their teeth, we might be able to see the DNA from the plant material used to make the rope," Weyrich said.

But where did the idea of studying dental plaque come from?

Weyrich and Cooper were part of the research group that ignited this new research field in 2013 with the goal of understanding how health and disease has changed through time.

"This method really is a new groundbreaking way to do that," Weyrich said. "We figured out that we could obtain bacterial DNA from dental plaque that was calcified on ancient skeletons. This is the first time it has been applied on an extinct species.

Join the conversation See the latest news and share your comments with CNN Health on Facebook and Twitter.

"Being able to hold a Neanderthal skull, and essentially take him to the dentist, was certainly something you don't get to do everyday! It's difficult to convince a museum that they should destructively sample a Neanderthal for a brand new field of research. We're so glad that several groups put their trust in us and our research."

Being able to take a closer look at the DNA on these samples has also provided our best glimpse yet into the Neanderthal lifestyle. For example, it revealed more about the microorganisms present in modern humans that are actually shared with Neanderthals.

"These particular organisms looks to be shared between Neanderthals and humans about 120,000 year ago, or about the time that humans and Neandertals were interbreeding," Weyrich said. "These interbreeding encounters were often described as brash, rough one-night stands, but if they were swapping oral microorganisms, it means they were also swapping spit. So, potentially kissing or food sharing would have been involved, which suggests that these encounters may have been much more friendly than anyone imagined."