I'm not as comfortable here as the other answer writers. I can't be as certain as they seem to be that "all will be well."
I think you should take some action, actually. First, find out why your paper is delayed from your own editor and point them to the "duplicate." (See below for a caveat, however)
Second, try to determine if the other paper is an example of parallel research or a possible plagiarism. In mathematical subfields with a lot of research interest, parallel work is very common. Everyone has access to the same background work as everyone else.
But it is also possible that you were plagiarized from a public preprint and you should explore that avenue as well. It isn't impossible, in fact, that a reviewer has acted unethically here. Those are both reasons for pointing your editor to the other paper. If there is evidence of plagiarism they can help you with the response.
However, if you have already paid fees (or your grant did, or your institution) or if you have already transferred copyright to the publisher then you can insist on it being published. I'm still not assured that you would win a dispute with your publisher, however, as they can return both fees and copyright. That may, itself, be unethical, but probably difficult to fight.
I note that there is some risk involved in pointing your editor to the other paper, if they take the existence of the other publication as a reason to back out of publishing your work. An alternative is to first ask the editor for a publication date. If they tell you they are reconsidering, then ask why. If it is because of the other article, point out the history of the two papers. I agree that you should have priority here, but resolving it can still be difficult.