Unless a song is instrumental, lyrics are usually the first song element written. Many musicians keep a notebook handy and jot down lyrics wherever the lyrics come to mind. You may be sitting around with a guitar, strumming chords and happen upon a chord progression you feel will go with a particular lyric you've written. Many songs come together in this way. In fact, some musicians have a melody in mind when they write a lyric, which makes it easier to compose once they come to the chord stage.
Chords are the fundamental building blocks of any song, whether there are chords actually being played or simply implied by the notes included in a song. Having a chord vocabulary and knowing how the chords sound when played together is the first step to using a guitar to write songs. Many musicians who use a guitar for songwriting are not guitar players, but they know enough chords to strum out a song progression upon which to build their tunes. Keeping a chord book handy or using one of the free online chord dictionaries is a good idea for songwriters (see Resources). Strum chords while you sing your lyrics. This will help you find the chords that go with your words, find the key you want to sing in and help define the melody.
Once a songwriter has chosen and laid out the chords he will use, and the lyrics are placed over the chords in verse/chorus fashion---perhaps with a bridge and an outro---the songwriter will usually take the piece to their band, and individual band members will work out their instrumental parts. Some songwriters who work better on their own will write all the parts, whether on individual instruments or even on guitar. Typically, a guitar solo will be added, based around the melody and played over a verse or verse chorus progression. The songwriter will add other instrumental parts, developing the song layer by layer, often using a recording device to play the chord and vocal progression while they work out other parts. It's through this tedious, creative process that the hits are born.