The nightmare is over -- for all parties involved.

Following through on owner Stephen Ross' words that neither Jonathan Martin nor Richie Incognito would return to the Dolphins after the 2013 harassment scandal, the Dolphins confirm they have agreed to trade Martin to the San Francisco 49ers.

Martin thus rejoins former Stanford coach and current San Francisco coach Jim Harbaugh in the Bay Area.

Terms of the trade were not immediately available. But it is likely for a low-round pick. ESPN was the first to report this story.

The Dolphins invested a second round pick on Martin in 2012.

In 2013, Martin imploded.

Plagued by depression and self-esteem issues, and tormented by poor treatment from Incognito, John Jerry and Mike Pouncey, Martin admits in the Wells Report he felt suicidal in May 2013.

In late October he left the Dolphins in the middle of the season.

Now he's left the Dolphins for good.

Martin's reaction?

"Big news," he tweeted moments ago. "Opportunities are few in the NFL. Can't wait to get to work."

He added the hashtag: 9ersempire.

The Dolphins will carry $959,734 in dead money against their cap for the Martin trade.