Ed Sheeran may not have faced off against any fire-breathing dragons lately, but he did channel his inner dwarf while writing "I See Fire" for Peter Jackson's "The Hobbit: The Desolation of Smaug."

"I've never been a dwarf, but I've wrote a song from the perspective of being a dwarf," he told MTV News of the song, which he said was inspired by the '70s folk band Planxty.

Sheeran wrote the track immediately after viewing an early screening of the film, when Jackson instructed him to pay special attention to its epic conclusion.

"Peter said, 'Focus on the last 10 minutes. That's what the song needs to reflect,'" Sheeran recalled. "He said, 'Write a song that takes the audience by the hand and leads them from Middle Earth back into reality.' So, yeah, I tried to do that."

The folksy ballad touches on all the key "Hobbit" themes: fire, mountains and brotherhood. Picking up right where the first "Hobbit" left off, the second installment of Warner Bros.' three-part series finally introduces viewers to Benedict Cumberbatch's terrifying Smaug.

"If this is to end in fire/ Then we shall all burn together/ Watch the flames climb high/ Into the night/ Calling out 'father'/ Stand by and we will/ Watch the flames burn auburn on the mountain side," Sheeran croons on the track, playing as the end credits begin to roll. Sheeran was on hand Monday for the film's world premiere in Hollywood, where he rubbed elbows with stars Cumberbatch, Martin Freeman, Evangeline Lilly, Richard Armitage and more. Actor Luke Evans, who plays Bard the Bowman, snagged a photo op with Sheeran at the after party, calling the encounter "one of the highlights of the evening."

"I actually forgot my song was in the film," Sheeran said of the premiere, a repeat viewing for the 22-year-old. "I'm such a Tolkien and Peter Jackson fan, I was watching the film just assuming that was the premiere to watch the film. I was watching it and then the song came on and I was like, 'Oh, yep. That's why I'm here. Cool.' But I was enjoying it that much, I forgot. "