Angelina Jolie and Brad Pitt's contentious custody battle is finally over.

The estranged couple has reached a custody agreement, allowing them to avoid what could have been a nasty trial, Us Weekly reported. Jolie, 43, and Pitt reached the agreement a few weeks ago with the help of a "child custody evaluator."

"A custody agreement was agreed to weeks ago and has been signed by both parties and the judge," Jolie's lawyer, Samantha Bley DeJean, said. "The agreement, which is based on the recommendations of the child custody evaluator, eliminated the need for a trial. The filing and details of the agreement are confidential to protect the best interests of the children."

Although DeJean wouldn't reveal anything about the agreement Jolie and Pitt, 54, signed, sources close to the Fury actor have shared several details. According to insiders close to Pitt, he and his ex will have joint custody and his "monitored visits" will end.

"Brad and Angelina will have joint physical and legal custody of the children. Over a period of the next six to eight weeks, the monitored visits will come to a conclusion. The children will immediately begin to have overnight visits with their father. The monitors will be in place for those first overnight visits, and this was done at Brad's request. Brad recognized this is going to be a change from what the norm had been and wants to make the transition as smooth as possible."

Before they reached their agreement, Pitt say "the children every other day." A source revealed that he had them "four hours a day on school days and 12 hours on non-school days."

The former husband and wife were set to go to trial on Dec. 4. Pitt had been vying for joint legal and physical custody of the six children he and Jolie shared, while she wanted physical custody for herself, court documents obtained by Us revealed.

They requested Judge John Ouderkirk, the same judge who officiated their wedding, stay on their custody case until Dec. 31, 2019. He was initially slated to be off the case by June 30.

Despite all of this, Pitt is said to have been pleading with his ex to settle with him out of court. An insider said he feared the trial would leave his children with "lasting psychological damage."

At the time, the source said, "There will be no winner, no matter what the judge decides."

Although a source close to her claimed that Jolie was "not backing down" at the time, it appears she's had a change of heart.

More From KISS FM