Like many songs today, the Psalms were poetry put to music. But unlike Western poetry, Hebrew poetry is based not on rhyme and meter, but on parallel thoughts set beside one another. These parallels can be a restatement of the same idea (synonymous parallelism), present opposing ideas (antithetic parallelism), or be in some other relationship, such as chiasm (A-B; B-A). These parallels are then grouped in sections (strophes) that are arranged to give structure and meaning to the poem.
This psalm breaks logically into 7 strophes. The first and last (7th) concern the House (the Temple) of Yahueh. Notice that these two (strophes 1 and 7) are in a chiastic relationship to one another (A-B; B-A), where A is a positive emotion of the speaker, and B is the House of Yahueh. Because of the House of God, the speaker starts with an attitude of excitement about going up to Jerusalem, and ends with a wistful longing for the city's good.
The 2nd and the 5th strophes concern the physical structure of Jerusalem, her gates, her wall, and her citadels (or perhaps “palaces”). The 2nd strophe is in a modified chiastic pattern (A-B; B-C), built around the poetic repetition of "Jerusalem." The 5th strope has a synonymous form (A-B; A-B), where A is the peace (shalom) of Jerusalem, and B is prosperity (shalvah). The poetic repetition of these similar sounding words with similar meanings* (along with the similar sounding words "ask" [shaalu] and "Jerusalem"** [Yerusha- layim]) gives a sense of the pouring out of welfare and blessing that these lines are calling for.
* Shalom also means prosperity and welfare in addition to peace.
** The second half of the name "Jerusalem" is based on the same root as the word for "peace" (shalom).
The 2nd strophe conveys not only the excitement of being in Jerusalem, but also gives a brief description of the city (see historical notes). The 5th concerns the personal relationship with Jerusalem that has been established by this visit.
The 3rd and the 6th strophes concern the legal ordinance of going up to Jerusalem for the festivals. This is carried out by the people of Israel, who are identified in the 3rd strophe as tribes and in the 6th strophe as friends and brothers. This change in terminology is an important part of the overall message of the poem: While the speaker begins his trip to Jerusalem at the instigation of others (“when they said to me”), at the end of the trip he speaks for himself (“now I speak”) of his own relationship to Jerusalem as well as to his brothers and friends: it has been a relationship-building experience.
The 3rd strophe (which has the form A-B; A-B) is built around the poetic repetition of the word "tribes" and of the name of God, which appears first in a short form (YAH) and then in full form (YAHUEH; see historical notes). The 6th strophe is shortened and of irregular construction (A-B-C), both of which have the effect of breaking the rhythm of the poem and emphasizing the final phrase: "Peace be within you."
The 4th strophe (A-B-B), which is the climax of the poem, gives the reason why the House of Yahueh (the Temple of Solomon) is in Jerusalem: because it is the royal capital of David. Here David was led by God to bring the Ark of the Covenant and establish a permanent place of worship. (Before this the center of Israel’s worship moved from place to place.) This joining together in Jerusalem of the religious and royal aspirations of the nation is the foundation of Israel’s Messianic hopes and dreams.
The two-fold repetition of the word “thrones” in this strophe (#4) balances the mention of the House of God at the beginning and end of the poem. This strophe is also shortened, which emphasizes it. This creates a pause that separates the description of the speaker's journey in the first part of the poem from his response to it in the second part of the poem.
The overall structure of the psalm, counting strophe by strophe, is therefore A-B-C-D-B-C-A.
Having gone with excitement to Jerusalem, the speaker returns with a love for the city and a desire for her welfare (shalom). From a passive, though enthusiastic, participant, he is changed into an active supporter of the city, prayerfully blessing her, and calling for others to do the same.