Image copyright Science Photo Library Image caption Artwork: T. rex was a formidable predator during the Cretaceous Period

As a big, active predator, the mighty Tyrannosaurus rex needed a way to cool down.

Now, scientists say that two large holes in its skull acted as a kind of internal "air-conditioning unit", to help the dinosaur lose heat.

These anatomical features on the top of the head were previously thought to have been filled by muscles.

But a team says it's more likely this area was filled with blood vessels that helped T. rex regulate its temperature.

Large animals need special ways to cool down, since their immense body heat can overwhelm them in hot conditions.

Mission Jurassic: Searching for dinosaur bones

Teeny T. rex relative found in US

Mighty T. rex 'walked rather than sprinted'

Casey Holliday, from the University of Missouri, and colleagues, used thermal imaging devices - which translate heat into visible light - to examine alligators at the St Augustine Alligator Farm Zoological Park in Florida.

"It's really hard to get a picture of an alligator skull in the wild, because they're always off away from you and they're dangerous to approach," he said.

"Being at the farm allowed us to get up and over fences and take images and video from the top down."

Image copyright Science Photo Library Image caption Alligators have blood-vessel-filled holes that help them regulate their temperature

They discovered that the alligators have blood-vessel-filled holes in their skulls.

"An alligator's body heat depends on its environment," said co-author Kent Vliet, from the University of Florida in Gainesville.

"We noticed when it was cooler and the alligators are trying to warm up, our thermal imaging showed big hot spots in these holes in the roof of their skull, indicating a rise in temperature. Yet, later in the day when it's warmer, the holes appear dark, like they were turned off to keep cool."

By examining fossils and 3-D images of Tyrannosaurus rex's skull, the scientists discovered that the dinosaur had similar holes.

In the past, scientists believed the two large features in the roof of the extinct predator's skull - called the dorsotemporal fenestra - were filled with muscles that assist with jaw movements.

But Casey Holliday says: "It's really weird for a muscle to come up from the jaw, make a 90-degree turn, and go along the roof of the skull.

"Yet, we now have a lot of compelling evidence for blood vessels in this area, based on our work with alligators and other reptiles."

Image copyright EPA Image caption T. rex appears to have had similar structures in its skull

Larry Witmer, a professor of anatomy at Ohio University, who was also involved with the study, commented: "We know that, similarly to the T. rex, alligators have holes on the roof of their skulls, and they are filled with blood vessels.

"Yet, for over 100 years we've been putting muscles into a similar space with dinosaurs. By using some anatomy and physiology of current animals, we can show that we can overturn those early hypotheses about the anatomy of this part of the T. rex's skull."

Casey Holliday added: "If you're an active predator, as we think T. rex probably was, at some point, you want to be able to shed heat, as much as you want to gather heat.

"Having a bed of capillaries (small blood vessels) up here in the skull roof provides a mechanism for these types of animals to collect heat or shed heat."

The findings have been published in the Anatomical Record.

Follow Paul on Twitter.