Lin-Manuel Miranda, the composer, lyricist, and star of “Hamilton,” says that Alexander Hamilton reminds him of Tupac Shakur. Photograph by Zach Gross

In April, 2009, Lin-Manuel Miranda, a writer, composer, and performer, received a call from the White House. The new President and the First Lady were planning to host an evening of live performances centered on “the American experience,” and Miranda was invited to participate. Miranda, who was twenty-nine, had spent the previous year starring in the Broadway musical “In the Heights,” of which he was the composer and lyricist. Set in Washington Heights, the show incorporated salsa and merengue with rap and hip-hop, blending them with more conventional Broadway tropes, to winning effect. “Heights” had won four Tony awards, including those for Best Musical and Best Original Score, and Miranda had accepted the latter with an effervescent rap that invoked “Sunday in the Park with George”: “Mr. Sondheim / Look, I made a hat! / Where there never was a hat! / It’s a Latin hat at that!” (He then pulled a Puerto Rican flag from the pocket of his tuxedo.) The White House likely expected Miranda to perform something invoking the Latin-American experience, and he was told that a number from “In the Heights” would be welcome.

Miranda had something different in mind. A few months earlier, he and his girlfriend, Vanessa Nadal, who has since become his wife, had been on vacation in Mexico, and while bobbing in the pool on an inflatable lounger he started to read a book that he had bought on impulse: Ron Chernow’s eight-hundred-page biography of Alexander Hamilton. Miranda was seized by the story of Hamilton’s early life. Born out of wedlock, raised in poverty in St. Croix, abandoned by his father, and orphaned by his mother as a child, Hamilton transplanted himself as an adolescent to a New York City filled with revolutionary fervor. An eloquent and prolific writer, he was the author of two-thirds of the Federalist Papers; after serving as George Washington’s aide during the Revolutionary War, he became America’s first Treasury Secretary. Later, Hamilton achieved the dubious distinction of being at the center of the nation’s first political sex scandal, after an extramarital affair became public. He never again held office, and before reaching the age of fifty he was dead, killed in a duel by Aaron Burr, the Vice-President, after a personal dispute escalated beyond remediation.

Miranda saw Hamilton’s relentlessness, brilliance, linguistic dexterity, and self-destructive stubbornness through his own idiosyncratic lens. It was, he thought, a hip-hop story, an immigrant’s story. Hamilton reminded him of his father, Luis A. Miranda, Jr., who, as an ambitious youth in provincial Puerto Rico, had graduated from college before turning eighteen, then moved to New York to pursue graduate studies at N.Y.U. Luis Miranda served as a special adviser on Hispanic affairs to Mayor Ed Koch; he then co-founded a political consulting company, the MirRam Group, advising Fernando Ferrer, among others. On summer breaks during high school, Lin-Manuel worked in his father’s office; later, he wrote jingles for the political ads of several MirRam clients, including Eliot Spitzer, in his 2006 gubernatorial bid. Chernow’s description of the contentious election season of 1800—the origin of modern political campaigning—resonated with Miranda’s understanding of the inner workings of politics. And the kinds of debate that Hamilton and his peers had about the purpose of government still took place, on MSNBC and Fox.

Hamilton also reminded Miranda of Tupac Shakur, the West Coast rapper who was shot to death in 1996. Shakur wrote intricate, socially nuanced lyrics: Miranda particularly admired “Brenda’s Got a Baby,” a verse narrative about a twelve-year-old girl who turns to prostitution after giving birth to her molester’s child. Shakur was also extremely undiplomatic, publicly calling out rappers he hated. Miranda recognized a similar rhetorical talent in Hamilton, and a similar, fatal failure to know when enough was enough. There was extraordinary dramatic potential in Hamilton’s story: the characteristics that allowed him to rise also insured his fall. When the organizers of the White House event called, Miranda proposed a rap about Hamilton, and they said yes.

That evening in May, Miranda and the other performers—among them Esperanza Spalding, the jazz bassist and vocalist, and James Earl Jones—were introduced to the President. Miranda asked him to sign a copy of “Dreams from My Father” that he’d bought at the airport. Onstage, Miranda announced that he was working on a concept album about Hamilton—“someone I think embodies hip-hop,” he said, to general laughter. He did not mention that he had written only one song. After Miranda explained that Hamilton represented “the word’s ability to make a difference,” he launched into complex lyrics that condensed the first twenty years of Hamilton’s life into four minutes. Slight of build, with dark cropped hair and thick stubble, Miranda paced the stage with coiled energy, rapping of “the ten-dollar Founding Father without a father / Got a lot farther by working a lot harder / By being a lot smarter / By being a self-starter.” His performance ignited a rising murmur of delight among the audience, and the Obamas were rapt: Miranda later heard that the President’s first reaction was to remark that Timothy Geithner had to see this.

Six years later, that song has become the first number of “Hamilton,” which opens at the Public Theatre on February 17th, with Miranda in the title role. Rooted in hip-hop, but also encompassing R. & B., jazz, pop, Tin Pan Alley, and the choral strains of contemporary Broadway, the show is an achievement of historical and cultural reimagining. In Miranda’s telling, the headlong rise of one self-made immigrant becomes the story of America. Hamilton announces himself in a signature refrain: “Hey, yo, I’m just like my country / I’m young, scrappy and hungry / And I’m not throwing away my shot,” and these words could equally apply to his dramatizer. Miranda has used as his Twitter avatar Hamilton’s portrait on the ten-dollar bill, slyly tweaked to incorporate Miranda’s dark eyes, humorously set mouth, and goatee.

“Hamilton” is not a gimmicky transposition of early American history to a contemporary urban setting. Miranda’s Founding Fathers wear velvet frock coats and knee britches, not hoodies and jeans. The set, by David Korins, is a wooden scaffold against exposed brick; the warm lighting suggests candlelight, and the stage is equipped with ropes and iron fixtures that evoke the shipbuilding—and nation-building—of eighteenth-century New York City.

Miranda presents an Alexander Hamilton of incandescent focus, abounding talent, and barely suppressed fury. Hamilton was known to pace and mutter to himself while composing his treatises, and onstage the rap soliloquy feels startlingly apt as his preferred mode of self-expression: “I imagine death so much it feels more like a memory / When is it gonna get me? / In my sleep? / Seven feet ahead of me? / If I see it coming do I run or do I let it be?” Miranda transposes Cabinet meetings into rap battles where participants face off while surrounded by whooping supporters. The debate over whether a national bank should be established to assume the states’ debts—Hamilton’s farsighted invention—becomes an animated exchange, in which he emerges victorious by disparaging Thomas Jefferson: “Always hesitant with the President / Reticent—there isn’t a plan he doesn’t jettison.”

It does not seem accidental that “Hamilton” was created during the tenure of the first African-American President. The musical presents the birth of the nation in an unfamiliar but necessary light: not solely as the work of élite white men but as the foundational story of all Americans. Thomas Jefferson, James Madison, and George Washington are all played by African-Americans. Miranda also gives prominent roles to women, including Hamilton’s wife, Eliza Schuyler (Phillipa Soo), and sister-in-law, Angelica Schuyler (Renée Elise Goldsberry). When they are joined by a third sister, their zigzagging harmonies sound rather like those of Destiny’s Child. Miranda portrays the Founding Fathers not as exalted statesmen but as orphaned sons, reckless revolutionaries, and sometimes petty rivals, living at a moment of extreme volatility, opportunity, and risk. The achievements and the dangers of America’s current moment—under the Presidency of a fatherless son of an immigrant, born in the country’s island margins—are never far from view.