The theme of Walt Whitman's poem "Oh Captain, My Captain" is the death of President Abraham Lincoln just as the Civil War ends. The themes of mourning the death of the one who was the captain of the ship (the nation) and rejoicing over the victory intertwine throughout the poem.
Walt Whitman expresses first the relief over the end of the trip (the war) and the prize attained (freeing of the slaves) before launching into mourning at the bloodshed and death of his dear Captain (the President). In the next stanza, he seems to be in a state of denial, urging the President to get up and enjoy the victory and hoping that this tragic circumstance is only a dream. He then intertwines both themes throughout the final stanza, going back and forth from death to victory and back to death.