Jennifer Lopez and Marc Anthony have agreed to an anti-paparazzi clause.

After two years, Jennifer and Marc’s divorce was finalised on Monday. The pair agreed to use their “best efforts” to avoid unwanted publicity in relation to their six-year-old twins Emme and Max, according to TMZ.

Jennifer received primary custody of Emme and Max in the divorce, with Marc having the kids seven days each month. However, nannies must be present when the tots are in his care, according to the website.

Additionally, Jennifer and Marc will each separately take the children trick-or-treating on Halloween.

Jennifer and Marc were married in 2004 and separated in 2011, with Marc filing for divorce in April 2012.

“These last four years, I felt like I really had to look at myself. One of the things I realised was I had to love myself a little bit more,” Jennifer previously told the Los Angeles Times. “That was a huge lesson for me.”

The American Idol judge has been married three times, including once to Marc, and her two-and-a-half-year relationship with Casper Smart, 27, recently ended.

“The breakup [of my marriage] just made me go make some real realisations about myself. When you get to the point of loving yourself… you start going, 'OK, well, who am I? Myself happens to be many things. Do I love all those parts? The good parts, the messy parts.’ And when I said that, so many things happened for this album,” Jennifer told the Los Angeles Times, explaining the inspiration for her new record A.K.A, which hits stores on June 27.