The songwriting collaboration is a first between Foster and will.i.am. Regarding his intentions for the song, will.i.am said to Oprah Winfrey on her show: "The meaning of this song is being proud of America. I wanted to write the new American anthem for this day and age—for this generation." will.i.am previously recorded a tribute to Obama, "Yes We Can", based on Obama's speech after the 2008 New Hampshire primary.
Foster and will.i.am said that they wrote most of the song in a single evening at Foster's home. The recording came together quickly. Foster recorded Hill's vocals on January 15 in Tennessee, will.i.am recorded Bono's portion on January 17, and Blige contributed her vocals on January 18, right after performing at Obama's pre-inauguration concert at the Lincoln Memorial. Seal travelled to D.C. from Cannes to record his part on January 17–18.