Several San Diego police swarmed in on former UFC bad boy War Machine last night and threw a spit bag on his head after cops say the dude assaulted someone with a deadly weapon.

TMZ has learned Machine -- which is the fighter's legal name -- was arrested outside a bar called Thruster's Lounge around 11 pm.

Law enforcement sources tell us Machine and another male were fighting with bouncers -- and when cops tried to approach the situation, War Machine took off running.

Eventually, cops caught up with the 28-year-old, threw him in handcuffs, and for some reason, put a spit bag over his head ... which is generally applied when the perp gets a little too aggressive with his oral fluids.

Machine was arrested for assault with a deadly weapon -- though it's unclear what the weapon is. He's currently being held in a SD jail.