TMZ has learned "Jackass" star Bam Margera has been hospitalized after being attacked by a bat-wielding woman.

Cops tell us ... it happened at 2 AM this morning, outside Bam's bar in West Chester, PA. There was some sort of fight, that ended when the woman allegedly hit Bam in the back of the head with a baseball bat.

The woman was arrested and charged with assault.

Bam was taken to the Chester County Hospital. His condition is unknown.