Mary Max, the wife of world-renowned psychedelic artist Peter Max, killed herself in her Upper West Side apartment over the weekend, police said Monday.

Mary Max, 52, died of nitrogen asphyxiation and was discovered in her apartment on Riverside Drive near West 84th Street on Sunday evening, cops said.

She had been involved in an ugly legal battle with other members of the family over her dementia-afflicted, 81-year-old husband’s artwork.

In a 2015 lawsuit, Max’s stepson, Adam Max, accused Mary of attempting to kill her husband so she could take control of his multimillion-dollar art collection.

In response, Mary accused her stepson — who is three years younger than she is — of stealing $4.3 million worth of artwork that her husband gave her in a prenuptial agreement.

Peter, who married Mary in the late 1990s, grew old and frail in recent years and grew ill during the court cases over his fortune.

Peter Max rose to fame in the art world during the pop art era of the 1960s and 1970s.

He grew extremely wealthy painting for private organizations, including the NFL, FIFA and cereal companies.