Playwright, lyricist, composer and actor Lin-Manuel Miranda, left, with historian and author Ron Chernow at the National Archives Museum on Sept. 25 in Washington. (Leigh Vogel/Getty Images for National Archives Foundation)

The National Archives Foundation’s annual gala Sunday night was a mutual geek-out between the folks behind the smash-hit “Hamilton” and the home of Alexander Hamilton’s papers that helped inspire it.

Historian Ron Chernow, whose Pulitzer Prize-winning biography of the Founding Father was the basis of Lin-Manuel Miranda and Thomas Kail’s Broadway adaptation, recalled that when he first combed the Archives’ collection in 1998, he feared that Hamilton’s legacy would fade into obscurity. Now, Hamilton-mania is a genuine phenomenon.

“Hamilton, thank God, left a very, very extensive paper trail,” said Chernow, who was one of the evening’s honorees — along with Miranda and Kail, the musical’s director.

Miranda, too, credited the institution for providing the raw material of his career-making hit. “This is a building full of what survives. Without these documents, without these gems and genuine artifacts, there’s no story to tell,” he said.

At $1,000 a head, nearly 300 people, including White House senior adviser Valerie Jarrett and documentarian Ken Burns, were granted access to “the room where it happened.” (“It” being a 90-minute program and, later, a three-course dinner.) The event raised nearly $600,000, making it the most successful gala in the Foundation’s history.

Kail, an Alexandria native, might have a best-director Tony on his shelf, but he said getting the award from the Archives was an even bigger deal — at least to his mom, Wendy Kail, an archivist at Tudor Place in Washington.

“I think the most excited I’ve been was calling my mom and telling her that we had a chance to come here,” Kail said.

More history nerding-out: Before the black-tie festivities, Chernow and the other awardees were treated to an “extra goodies” tour of the Archives collection, which featured a first copy of Hamilton’s record of public credit and a handwritten letter from his wife, Eliza Schuyler Hamilton.

For Miranda, a first-time visitor of the Archives, the experience was eye-opening.  “I’m here with a pang of regret that there are so many treasures that I didn’t see [before] firsthand,” he admitted. But the “West Wing” buff made up for lost time. “Tommy and I are definitely doing our best Sam Seaborn and Toby Ziegler impressions, walking these hallowed halls,” he said.

The three luminaries discussed, among other topics, their collaborative process and how they were able to use primary documents to flesh out Hamilton’s life story. Audiences were rapt, happy to experience an early taste of Hamilton-mania before the musical makes its way to the Kennedy Center in 2018.

Ron Chernow, Lin-Manuel Miranda and Thomas Kail at National Archives Museum on Sept. 25. (Leigh Vogel/Getty Images for National Archives Foundation)