Use a half-speed playback device to slow down fast or hard-to-hear musical passages. This can be a CD or tape player or a piece of software that allows you to play songs back at half speed or slower. Newer models let you slow songs down to various speeds. One of these devices can be a huge benefit when you're trying to play a song by ear. Just remember, slowing a song down drops the pitch, so you will play the note you hear higher when you learn it.
Try to find the key center first. You can do this by playing chords along with the song until you find the correct chords. Don't worry about getting it perfect at first. Play a chord. If it sounds bad, play another. Continue to do this until you have found the chord changes in the song. Make a note of the chord changes. If you have trouble finding full chords, play one note at a time until you find notes that go consistently, then build your chords around that note one at a time until you have full chords that match the song.
Break solos and other difficult passages down into manageable chunks. Small musical phrases are easier to work with. You can slow the passages down until you have the rhythm and pitches, then practice playing the song up to speed. Connect your phrases together one at a time, practicing each new song segment you learn until you are playing it fluently.
Train your ear and exercise it regularly. You can do this several ways. Play notes on your instrument and try to guess what the notes are. Play major and minor chords in every key and listen for the subtle differences in the tones. They won't be immediately noticeable, but the more developed your ear becomes, the better you will be able to distinguish these differences. You can also use ear-training software or an online ear-training website to help you identify chords, notes and key signatures (see Resources).