BITTER accusations of cheating and be­trayal have turned BARBRA STREISAND’s $390 million divorce from husband JAMES BROLIN into an ugly, all-out war, say sources.

And sexy “Castle” star Stana Katic is now said to be caught in the middle of the couple’s nasty battle.

Tensions between the two have been running high for some time. As The ENQUIRER reported in November, James was complaining that Barbra’s con­trolling ways have driven him to the breaking point.

But now the “Funny Girl” star has gone on the offensive. Insiders tell The ENQUIRER that Barbra “hit the roof ” after she recently learned of allega­tions regarding James’ secret cheating past. She then accused him of having an affair with Stana during the blowout fight that followed at their Malibu estate, although there is no evidence they have done anything more than flirt.

“Barbra feels betrayed because James has said he wants out of the marriage,” revealed a source. “But it got even worse when word got back to her that he’s flirted with Stana.

“On top of that, she just discovered he cheated on his first wife. It’s almost like she doesn’t know the man she’s been married to for 15 years.”

Biographer Mark Bego, who has been research­ing Barbra’s life for a book, told The ENQUIRER: “After being cheated on by (first husband) Elliott Gould in the ’60s, the last thing Barbra wants is his­tory repeating itself. It was so devastating for her the first time, she couldn’t bear for it to happen again.

“But Barbra is such a control freak, she may be driving James away.”

That’s exactly what The ENQUIRER reported in our Nov. 11 issue. Sources said the Emmy-winning actor – best known for his TV roles in “Hotel” and “Marcus Welby, M.D.” – was so fed up with Barbra that he signed on for a slew of recent showbiz jobs in an effort to put some space between them.

 “James wanted distance from Barbra, but working on ‘Castle’ is what led to the latest eruption,” said a friend of the actor. “In reality, James did flirt with Stana – that’s how he is. But Barbra wonders what else went on.”

On “Castle,” Stana, 35, plays tough, no-nonsense NYPD homicide investigator Kate Beckett. James, 73, debuted as a guest star on the show last February in the role of gun-toting spy Jackson Hunt, who turned out to be the absentee father of the show’s title character, played by Nathan Fillion. The show hit a high of 17 million viewers and regu­larly attracts 12 million.

James recently returned to the set to shoot a second epi­sode, which aired on Jan. 13. During filming, he and Stana resumed their friendship, says the pal, and that didn’t go over well with Barbra.

“James went on and on about how delightful Stana was, how intelligent and beautiful she was and what a pleasure it was to work with her,” said the friend. “Barbra accused James of having an affair with Stana, and he shot back, ‘Don’t be ridiculous!’

“But Barbra refused to let it go, and they got into a terrible screaming match.”

What’s more, Barbra, 71, was furious because she believes another “Castle” actress – Susan Sullivan – also made a play for James.

After his first appearance on the show, Susan, 71, gushed to a reporter: “I’m hoping (produc­ers) bring (him) back, for God’s sake. That would be fun. He’s an attractive guy. And he’s tall…”

That was too much for Barbra, says the friend.

“She’s convinced James was flirting on and off the set with both Stana and Susan. Bar­bra read James the riot act, raging and yelling, ‘How could you?!’

“James has had enough.”

Adding to their mounting problems is the fact that Barbra only recently learned that his first wife, Jane Agee, alleged in divorce proceedings that she and James had an “open marriage.”

The ENQUIRER obtained court papers from their divorce, in which Jane alleged that James had numerous affairs during the union. Ac­cording to Jane, the marriage finally crumbled when James began dating his second wife, Jan Smithers, while still married to Jane.

“Barbra found the whole situation disgust­ing,” said the source.

The couple has been spending more and more time apart, and the friend says that James has been telling pals he’s fed up.

“They argue about everything, but their most vicious fights are over the cheating accusations,” the friend added. “It’s pushed their marriage to the brink and divorce may be the only option.”