Hello, It sounds like your X5 is having a problem with the throttlebody assembly. The abs system uses the thottle to control the traction control system and the DME uses the throttle to control idle speed. When this system goes bad it is usually the throttlebody assembly itself that fails. If it is replaced the adaptations need to be reset afterwards. This would explain why you can't accelerate over 1250 rpms and why it goes into a surge. You could try cleaning the throttle plates but unless they are binding it won't help. Since it is a self contained unit (built in motor and sensors) usually only replacement fixes the problem Good luck.
If this information was helpful please hit accept. Thanks, Nick
ASE Certified Technician
Over 25 years of experience in automotive computer systems. ASE L1 Cerfification