A metaphor that continues over several lines or throughout an entire poem is called a conceit. Conceits were a particularly important element in English poetry in the 16th and 17th century.
The word conceit is related to the word conceive; a conceit is a thought that is formed, or conceived, in one's mind. The use of conceit to refer to vanity and excessive self-esteem is based on an old phrase self-conceit, which was later shortened to conceit.
A famous example of conceit is Shakespeare's Sonnet 18. In this sonnet, Shakespeare compares his beloved to a summer's day in a number of way, in each way finding his beloved superior to summer:
a) His beloved is "more lovely and more temperate";
b) Summer is sometimes too hot: "Sometime too hot the eye of heaven shines";
c) Sometimes the sun does not shine in summer: "Often his gold complexion dimm'd";
d) Summer eventually ends, but the beloved will live forever in the poem:
And every fair from fair sometime declines,
By chance or nature's changing course untrimm'd;
But thy eternal summer shall not fade
Nor lose possession of that fair thou owest;
Nor shall Death brag thou wander'st in his shade,
When in eternal lines to time thou growest:
So long as men can breathe or eyes can see,
So long lives this and this gives life to thee.