I had a similar issue on my BMW (same engine) when I started running on veg oil. Never actually got to the bottom of it but when I stopped running veg oil it went away. My symptoms were that I would be driving along fine, take my foot off the accelerator and the you put your foot back on there was nothing. Push your foot down more and the engine would die, speed drops and the revs drop below 1000 and the engine would start up again. If I just left my foot off the engine wouldn't die and would also come back on its own.
Reading up on the BMW forums is seems it's most likely to be the fuel pressure switch in the injector pump but a lot of BMW owners just replace the injector pump. It seems like a fairly common problem with BMW's. My fuel filter was really dirty when I got the car and the fuel tank wasn't very clean either. So I drained and cleaned the tank, replaced the fuel filter and I think I have a lot of debris in this fuel pressure jobbie in the injector pump. You can remove it and clean it as it has a little gauss filter, but I haven't done that yet.
Have you had it serviced recently? Has the fuel filter been replaced?