Justin Bieber recorded the track, Bigger, for his debut record, My World in 2009.
But the teen heartthrob did not know that singer-songwriter Frank Ocean had written the song about his break-up with his then boyfriend.
Ocean, 24, came out about his sexuality earlier this year.
The songwriter has also written tracks for Beyonce, Kanye West and other big names.
Discussing the Bieber track, Ocean wrote on his website: ‘Four summers ago I met somebody. I was 19 years old. He was too. We spent that summer, and the summer after, together. It was hopeless.’
An even more youthful Bieber was trapped by Rolling Stone magazine in 2011 into implying that he thought being gay was a 'choice' rather than something uncontrollable.
Here’s the Bieber track: