From Hamilton to Hogwarts! Lin-Manuel Miranda rapped about Harry Potter and Pop-Tarts, among other things, during an appearance on The Tonight Show Starring Jimmy Fallon Tuesday, October 4 — and it was magical.

Ahead of his October 8 hosting gig on Saturday Night Live, the Hamilton star, 36, proved that he can freestyle about pretty much anything when Jimmy Fallon challenged him to a round of Wheel of Freestyle.

Miranda, who faced off against The Roots' Black Thought, was given a series of three random words to use to create an improvisational rap. (Miranda previously played the same game during a November 2015 appearance on the late-night show.)

After a freestyle generator selected the words "robot," "corn maze" and "Harry Potter," the Broadway star launched into a hilarious verse, rapping, "Once again, I'm in a very tricky spot / I'm going to win the Emmy like Mr. Robot / And I could go for days and days / But yo, I'm lost but plenty to eat in this corn maze / Oh yeah, I'm going above and beyond / I'm Sirius Black, I got my magic wand / And oh yeah, there ain't nothing you can do to harm us / Avada Kedavra and Expelliarmus!"

For his second challenge, Miranda had to use the terms "Pop-Tart," "unicorn" and "Election Day" — and things got, uh, a little NSFW.

"I know that rap was tragic / But I'm a unicorn, brony, and friendship is magic," he freestyled. "So, um, I got an erection today / I can't wait to make my choice on Election Day!"

As Fallon, 42, and the crowd laughed at the hilarious rap, Miranda stood up and showed his support for Democratic presidential nominee Hillary Clinton, saying, "I'm with her."

Watch the video above!

The Tonight Show Starring Jimmy Fallon airs on NBC weeknights at 11:35 p.m. ET.

Want stories like these delivered straight to your inbox? Sign up now for the Us Weekly newsletter!