I hate to say it but what has happened is the transmission has overheated and basically cooked itself from the inside.
I have seen this problem more than I want to, Mazda uses the same cd-4 trans in the 626 and we replaced them as if we were doing oil changes. Also just put a reman trans from ford in my contour cost me about $2700.00. Mine done exactly the same thing o/d light flashed and trans would slip.