John Mayer is poised to release his latest album, Battle Studies, later this month. And while fans will enjoy trying to figure out which songs could possibly be about Jennifer Aniston, they will also get to hear his sweet duet with Taylor Swift.

"She is on the record," he told MTV News, adding that the collaboration, which appeared online Thursday, originally came together after he tweeted that he wanted to work with the singer. "You know what? It's like the tweet version of 'The Secret' — no better way to put it out into the universe than to tweet it."

Swift also openly expressed a desire to work with Mayer in interviews, but the details of how it actually came to be are a bit fuzzy to Mayer. "Well, you know, tweeting it is more just sort of the exposition of my idea," he explained. "But then it's not like she reads the tweet and goes, 'I'm in,' although she may have. I don't remember."

The idea for the song came to Mayer in a dream. "I woke up with the song in my head called 'Half of My Heart,' " he recalled. "And the idea is that it's this real sort of updated — not that it needs to be updated — sort of Tom Petty, Fleetwood Mac, Stevie Nicks thing."

On the track, Mayer sings lead with Swift lending backup vocals. "I thought, 'Well, if this is going to be my love letter to that style of music, who's going to be the Stevie Nicks in this equation?' " he recalled. "And I thought, 'This Taylor Swift girl is going to be around for a long time.' "