It sounds electrical to me. Check the battery connections - not only at the battery but also the other ends of the cables. It could also be your ignition switch, they have been know to have problems. The switch does not just connect two wires, which would be the simple way. It connects two power source cables to five or six other wires. Therefore one of those connections could be corrupt, causing the engine to fail, but still be good in other areas such as the fuel pump.