It's a complicated ongoing situation at the moment, but it looks like his slow-moving purge of oversight (one person every couple weeks, all on late-night Fridays, ala Iran-Contra) inevitably ran into someone who would contest the dismissal.
And Berman has a lot of cards in his hands. He was chosen by the current administration three years ago, as an unconfirmed 'acting' head of the SDNY. He was then appointed permanently to the position by the SDNY judges because the exective branch left the position vacant after 120 days, as per statue.
That means the AG can't fire him, as he's a judicial appointment, not an executive one. There is an old OLN memo that suggests that the president personally may have the authority to fire him, under a wide blanket. He certainly has enough to contest the dismissal, in which case it'll probably go back to the Supreme Court, which will take at least six months, meaning Berman will stay for at least that long.
He also has more cards, because of the utter incompetence of the administration's malice. Barr in his Friday night press statement both said that Berman was 'resigning' and that he was going to be offered a promotion to a key position. It was going to be fradulent, as that was a similar strategy to remove another person. Offer a promotion, accept resignation, remove promised position, and you fire someone without firing them.
..but stating in writing that the person in question is going to be considered for a higher position removes quite a lot of 'He was incompetent, so I fired him' ground, at least if it ever sees a judge.
..secondly, lying that a person is resigning when the person is being fired via press-release is simply incredibly dirty. After that person than makes it absolutely clear that he isn't resigning, it makes that whole statement an obvious, blatant lie.
And then Barr writes another letter, claiming that he asked the president for his dismissal (quite possibly true) and that the president granted it (also quite possibly true.. the parnas tapes make it clear basically any of his insiders can ask for people to be removed), and that Berman should consider himself fired by the president.
Of course, that letter was unsigned and not actually from Trump, followed with Trump saying to reporters that he's not involved in it at all and that it's all up to Barr, which completely undercuts the letter Barr just wrote.
It's just horrifically corrupt and autocratic. Hasn't even provided a flimsy reason for the dismissal in all this. I'm not going to speculate on why, because the list of SDNY investigations that they could want stopped is longer than this post.