Ah, that old question. I've deliberately done it differently for different songs, to see which works best for me. I'm still experimenting. Here's the order I got the ideas for the songs on my EP "Some Songs I Wrote":
1. "Let it Go" Chords and rhythm first, then the hook line ("Let it go"), then the theme, then the melody. (By "theme" I mean what the song is about).
2. "A Special Request" Theme first, then some lines, then rhythm and style, then melody, then chords.
3. "Bipolar" Rhythm first, then chords, then melody, then some lines, then theme.
4. "When They Go" The music and the theme were developed independantly. After going through my library of music ideas for the song, I remembered this chords/rhythm idea, and decided to use it. Then I found melody for the initial lines I had.
5. "Invisible Prison" Theme first, then melody and rhythm, then lines, then chords.
6. "The Screwup Song" Melody and rhythm first, then lines, then theme, then chords.