In a deeply personal TV interview, Meghan told Oprah Winfrey that she did not get help when she asked for it.
She said a low point was when Harry was asked by one member of his family "how dark" their son's skin might be.
Prince Harry also revealed that his father, Prince Charles, stopped taking his calls when he wanted to step back.
The highly-anticipated interview with Oprah aired overnight in the US.
During the two-hour CBS special, to be aired in the UK on ITV at 9pm on Monday night and on ITV Hub, Courtesy of Harpo Productions/CBS, the couple covered a range of topics, including racism, mental health, their relationship with the media and Royal Family dynamics.
They also announced their baby, which is due in the summer, is a girl.
The couple moved to California after formally stepping down from royal duties in March 2020, and it was announced last month that they would not be returning as working members of the Royal Family.
'I was not being protected'
Meghan said that she started to feel lonely when limits were placed on what she could do, revealing that at one point she did not leave the house for months.
At one point she thought she "could not feel lonelier", she told Oprah.
Asked by Oprah if she was thinking of self-harm and having suicidal thoughts at some stage, Meghan replied: "Yes. This was very, very clear. Very clear and very scary. I didn't know who to turn to in that."
12 things we learned from Meghan's Oprah interview
Royal Family tree and line of succession
In pictures: Harry and Meghan's life together
Meghan said that she felt "haunted" by a photograph from an official event she attended with Harry at the Royal Albert Hall while she was pregnant.
"Right before we had to leave for that (event), I had just had that conversation with Harry that morning," Meghan said.
Winfrey asked: "That you don't want to be alive anymore?"
"Yeah," Meghan confirmed.
She said that she attended the event with Harry that night because she felt she could not be "left alone" and recalled Harry gripping her hand tightly while in attendance at the Royal Albert Hall.
Oprah also asked Meghan why she thought the Royal Family did not make her son Archie a prince.
The Duke and Duchess of Sussex's children do not automatically become princes or princesses because of a rule that has been in place since 1917 - unless the Queen steps in.
"In those months when I was pregnant, all around this same time so we have in tandem the conversation of he won't be given security, he's not going to be given a title, and also concerns and conversations about how dark his skin might be when he was born," Meghan said.
She said the remarks were made to Harry and he relayed them to her.
Asked by Oprah whether there were concerns that her child would be "too brown" and that would be a problem, Meghan said: "If that is the assumption you are making, that is a pretty safe one."
When pressed, she refused to reveal who the individual was, saying: "I think that would be very damaging to them."
The Duke and Duchess of Sussex being interviewed by Oprah Winfrey
Harry also refused to give further details, saying: "That conversation, I am never going to share."
"At the time it was awkward, I was a bit shocked," he added.
He said that none of his relatives spoke out in support of Meghan following the racism he said his wife faced from the media.
"No-one from my family ever said anything over those three years. That hurts," Harry said.
Summer 2016: Harry and Meghan meet on a blind date organised by a mutual friend in London
May 2018: The couple marry at Windsor Castle
April 2019: They move to Frogmore Cottage in the grounds of Windsor Castle
6 May 2019: Their son Archie is born
31 March 2020: They officially step down as senior royals after moving to Canada. They move to California later that year.
14 February 2021: The couple announce they are expecting their second child
19 February 2021: Buckingham Palace confirms they will not return as working members of the Royal Family and they are stripped of their patronages
During the interview, the Royal Family were also accused of failing to protect the duke and duchess, with Meghan saying the situation "started to really worsen" after the couple married in May 2018.
"I came to understand that not only was I not being protected but that they were willing to lie to protect other members of the family.
"But they weren't willing to tell the truth to protect me and my husband."
She was referencing rumours that she had made the Duchess of Cambridge cry during a disagreement about flower girl dresses - a story that prompted a flurry of tabloid stories.
Meghan said the opposite happened. She added that Catherine later apologised, bringing flowers and a note to make amends.
Joining his wife and Oprah for the second half of the interview, Harry talked about his relationship with the rest of his family.
He said his relationship with his grandmother, the Queen, was "really good" and that the two of them speak often.
However, his relationship with his father, the Prince of Wales, has suffered.
Harry said that he feels "really let down" by his father. He added that he will always love him, but "there's a lot of hurt that's happened".
Of Prince William, he said they were on "different paths".
Harry also revealed that his family had cut him off financially at the beginning of last year, after the couple announced their intention to step back as senior royals.
He said deals with Netflix and the Spotify were "never part of the plan" but they needed them to pay for security staff.