Former Miami Dolphins offensive lineman Jonathan Martin will avoid prison time after reaching a plea deal Friday on charges related to a threatening post on his Instagram account in February 2018.

As part of the agreement, three felony charges against Martin will be dropped in two years if he attends scheduled psychotherapy sessions, alcohol counseling and psychiatric appointments.

The image on the post showed a shotgun and ammunition and tagged four accounts, including those belonging to former Dolphins teammates Richie Incognito and Mike Pouncey. It also included hashtags for Harvard-Westlake, where Martin went to high school in the Los Angeles area, and the Dolphins.

The caption read: “When you’re a bully victim & a coward, your options are suicide, or revenge.”

“I am thankful that this matter has finally come to a conclusion. I want to apologize to my high school alma mater for my reckless and selfish actions,” Martin said in a statement Friday. “I am eager to put this matter fully in the rear view mirror and to continue forward with my life. I plan to eventually speak more candidly about mental health, substance abuse, and selfishness, and ultimately about perseverance & personal triumph.”

A prosecutor said the people named in the post supported the plea deal’s terms.

At the time of the social media post, Martin, 29, was detained for questioning and released, a spokesman for the Los Angeles Police Department told ESPN. Nine days before the post, a gunman killed 17 people at a high school in Parkland, Florida.

Martin accused Incognito and Pouncey of bullying him in 2013, when they were teammates in Miami, which resulted in an NFL investigation. The investigation found that Incognito, Pouncey and John Jerry created a hostile working environment for Martin, who left the team in the middle of the season.

The NFL suspended Incognito for eight games after the investigation was completed.

Martin hasn’t played in the NFL since 2015.