The ancient Mayans were masters of time, keepers of good calendars.

And now we have one of their timekeepers’ workrooms to prove it.

In a striking find, archaeologists in Guatemala report the discovery of a small building whose walls display not only a stunningly preserved mural of a brightly adorned Mayan king, but also calendars that destroy any notion that the Mayans predicted the end of the world in 2012.

These deep-time calendars can be used to count thousands of years into the past and future, countering pop-culture and New Age ideas that Mayan calendars ended on Dec. 21, 2012, (or Dec. 23, depending on who’s counting), thereby predicting the end of the world.

The newly found calendars, which track the motion of the moon, Venus and Mars, provide an unprecedented glimpse into how these storied sky-gazers — who dominated Central America for nearly 1,000 years — kept such accurate track of months, seasons and years.

“What they’re trying to do is understand the large cycles of cosmic time,” said William Saturno, the Boston University archaeologist who led the expedition. “This is the space they’re doing it in. It’s like looking into da Vinci’s workshop.”

Before the new find, the best-preserved Mayan calendars were inscribed in bark-paged books called codices, the most famous being the Dresden Codex. But those pages hail from several hundred years later than the newly found calendars.

Saturno said researchers have long assumed that the Mayans had worked out the cycles of the moons and planets much earlier, but no evidence of such work had ever been found.

But in 2010, an undergraduate student working with Saturno, Max Chamberlain, stumbled onto the house as the team began to excavate at a Mayan city, Xultun, which, despite being known since 1915, had never been professionally excavated. Over the decades, looters had dug deep trenches to access buildings. One day at lunch, Chamberlain announced his intention to find paintings by crawling through the trenches.

Saturno scoffed. The buildings were too shallow — any paint on their walls would surely be long gone, erased by water, dirt, insects and encroaching tree roots.

But sure enough, Chamberlain stumbled onto a wall, open to a trench, showing two red lines.

A quick excavation revealed the back wall of the building — replete with a mural of a resplendent Mayan king, in bright blue, adorned with feathers and jewelry.

Saturno’s team brushed off the wall and “ta-da!” he said. “A Technicolor, fantastically preserved mural. I don’t know how it survived.” Saturno immediately e-mailed contacts at the National Geographic Society, which agreed to fund a full excavation of the building.

The mural is the first Mayan painting found in a small building instead of a large public space. And it’s also the oldest known preserved Mayan painting.

Next to the king, a scribe holds a writing instrument. Three mysterious figures wearing black also march across the wall. One of them is named “older brother obsidian.” Mayan experts have no idea whom these mysterious figures might represent.

Once the team uncovered several columns of red and black dots and dashes — the Mayans’ numbering system — the meaning of these figures was almost immediately evident to David Stuart, one of the world’s foremost experts in Mayan hieroglyphics. It was a lunar table, showing a 4,784-day cycle of the moon’s phases.

The table is broken into 27 columns, each representing six lunar months. Each column is topped by the face of one of three moon gods — a jaguar, a skull and a woman. These three repeat. So by consulting the table, a priest, say, could tell which moon god would preside over a particular date.

Want to know whether the king’s birthday falls under a jaguar moon 10 years hence? A thousand? Check the table.

“It’s really cool because it shows us the tools the ancient astronomers and priests were using to do their calculations,” Stuart said.

On another wall sits a smaller set of four columns of figures. These took a bit more puzzling. But eventually Saturno’s team figured it out: This second table was filled with huge numbers relating to how long it takes Mars and Venus to cross the sky and come back again. This calendar spans some 7,000 years — heading much farther into the future than the supposed doomsday date.

“Like a lot of ancient cultures, they were able with naked-eye astronomy to calculate the paths of the planets,” Stuart said. “We tend to forget that before telescopes, people were able to analyze the movement of planets in a lot of detail — and figure out exactly, to the day, the length of a Venus year and a Mars year.”

Heather McKillop, a Mayan expert at Louisiana State University who was not involved in the research, called the Xultun murals “stunning new evidence of the ancient origins of Maya astronomical record keeping, best known from later documents.”

Tulane University’s Marc Zender, another Mayan expert not involved in the work, said that “it’s about as exciting as discovering lost manuscripts of a famous mathematician like Archimedes. It’s an amazing privileged glimpse over their shoulders.”

Saturno said the building had been filled in by the Mayans, heaped with dirt and rubble. “They just backed themselves out the door and left,” he said; no one knows why. But the fill probably helped preserve the paintings.

With the virtually unexplored city of Xultun containing hundreds of buildings stretching across at least 16 square miles of jungle, Saturno guesses that plenty of other surprises await excavation. “It might take another two decades,” he said.

He expects the world to still exist then and said he’d bet anyone a million dollars that it will. The Mayan calendar does start a new “long cycle,” later this year, but he equated that with the odometer on a car rolling over from 99,999 miles to zero: “You go, ‘Yay,’ but the car just doesn’t disappear.”

The discovery is detailed in this week’s Science magazine and in the June issue of National Geographic.