Alex Rodriguez is dealing with an ex from hell -- a woman who's hit him up for cash for years is now threatening to expose private messages if he doesn't cough up as much as $600k ... TMZ has learned. We're told A-Rod broke up with the woman back in 2014, and although It was never a serious relationship -- more of a fling -- she continued contacting him every now and then, asking for small amounts of money. We're told he always turned her away empty-handed. But things changed earlier this year when Alex got together with Jennifer Lopez. We're told the ex suddenly started hitting up A-Rod for larger amounts of money.

He did not give in, and finally within the last week ... he told the woman he was in a happy, committed relationship with J Lo ... and simply wanted to be left alone. That final denial set her off, and she insisted she would not be ignored. Think Glenn Close in "Fatal Attraction." We're told she demanded $600,000 or she would contact multiple media outlets to offer text messages Alex had sent her. One source with direct knowledge believes the woman's motives are clear: once A-Rod hooked up with J Lo ... the ex saw dollar signs, and felt he would pay any amount to keep her quiet.

The source believes she intended to release old texts with Alex from when they were dating, and make it seem like he was still contacting her while dating Jennifer. We're told A-Rod is standing firm ... he will NOT pay her a dime. Instead, his legal team is preparing to go to police and even federal authorities, if the woman continues threatening him. As for Jennifer ... we're told she's fully aware of what Alex is dealing with, and not only stands by him, but empathizes ... having gone through similar situations in her past.