The poem, by the same name as the movie, by William Ernest Henley, is referenced several times in the movie. While Mandela was incarcerated on Robben Island, the poem Invictus was a great source of strength and inspiration for him because of its message of self-mastery.
The first 3 stanzas of the poem are pretty inspiring. As President Hinckley said, "It is a great poem. It places upon the individual the responsibility for what he does with his life. Through these many years, when I have been faced with difficult choices I have repeated these stirring words."
Invictus
Out of the night that covers me,
Black as the pit from pole to pole,
I thank whatever gods may be
For my unconquerable soul.
In the fell clutch of circumstance
I have not winced nor cried aloud.
Under the bludgeonings of chance
My head is bloody, but unbowed.
Beyond this place of wrath and tears
Looms but the Horror of the shade,
And yet the menace of the years
Finds and shall find me unafraid
It matters not how strait the gate,
How charged with punishments the scroll,
I am the master of my fate:
I am the captain of my soul.
The last stanza, however, is rather defiant of any god or "higher power." In it, Henley basically says he can choose his own path, make his own rules, and that he is above any sort of punishment found in scripture.
After Henley wrote Invictus, Orson F. Whitney, a member of the Quorum of the Twelve Apostles in the early days of the Church of Jesus Christ of Latter-day Saints, wrote a response entitled The Soul's Captain.
The Soul's Captain
Art thou in truth? Then what of him
Who bought thee with his blood?
Who plunged into devouring seas
And snatched thee from the flood?
Who bore for all our fallen race
What none but him could bear. –
The God who died that man might live,
And endless glory share?
Of what avail thy vaunted strength,
Apart from his vast might?
Pray that his Light may pierce the gloom,
That thou mayest see aright.
Men are as bubbles on the wave,
As leaves upon the tree.
Thou, captain of thy soul, forsooth
Who gave that place to thee?
Free will is thine -- free agency
To wield for right or wrong;
But thou must answer unto him
To whom all souls belong.
Bend to the dust that head "unbowed,"
Small part of Life's great whole!
And see in him, and him alone,