A melody is a sequence of musical tones with definitive rhythm, pitch, and timbre, arranged in such a way to create, in the listener's mind, a definitive musical shape.
A melody is divided into measures, and even further, into notes. A melody typically follows a scale or mode, and music that does usually sounds more "congruent" and is considered "less challenging" (sorry, mild sarcasm on that last one). Melody in the western context is usually written in four keys: major, minor/natural minor (aeolian), harmonic minor, or melodic minor. Western music is also commonly written in modes, or keys starting on a different note of the scale other than the first.
However, a song does not have to use Western methodologies of creating music to have melody. Any piece of music, regardless of country of origin, can have melody.
Melodies end on what is called a cadence. These are marked "ending points" of a section of music.
If harmony is factored into the equation, especially with counterpoint, the melody is typically thought of as the dominant tune of the melody (usually the top set of notes because our ear "picks those up" first), although all of them are technically melody and all of them together form a sort of "macro"-melody.
Every song, with the exclusion of drum solos, some avant-garde compositions, a few pieces of electronica, and the like, has melody. Melody can be found in a song even if it is rapped, screamed, spoken, sung, shrieked, or whatnot.