Killer idle

My 2000 Nissan pathfinder died on the freeway the other day when I got it home it wouldn’t start, but turns over. I put some starter fluid in the intake and it started till what I sprayed ran out. So I figured it was a fuel problem. Replaced the fuel pump, and it started but now it has a rough idle and dies as it goes under 1k rpm. If I keep it reved above 1k it will keep going, but once I take my foot off the engine it gets really rough and klunks and dies. So is it something like the knock sensor or another part of the ignition or something worse like a blown head gasket?? Help!