In the final hours of her life, Jackie Kennedy Onassis lay in the bedroom of her New York City apartment, surrounded by a group of close friends and relatives, including one of America's most popular singer-songwriters.

“It’s seared in my brain what she looked like,” Carly Simon told NBC News. “She was so ravishing, and wearing this little handkerchief scarf, paisley scarf on her head, and looking so beautiful and so regal and so finally at home.”

Onassis’ death in 1994 closed a chapter in the fabled story of the Kennedys, America’s most famous political family. But it also marked the end of an extraordinary relationship between the reserved and refined former first lady and the free-spirited singing sensation 16 years her junior.

Simon describes her friendship with Onassis in a new book, “Touched by the Sun: My Friendship with Jackie.” In a remarkably candid interview, Simon detailed their unlikely relationship and described why she believes Onassis was drawn to her.

“I think she saw in me something that she wanted to have a little bit of herself,” Simon said in the interview that aired Tuesday on the “Today” show. “I think she saw a free spirit who had the license to be, in a rock and roll kind of way, loose as a goose. And I could smoke a joint if I wanted to.”

“She didn’t have the license to be free,” Simon added. “She was a naughty girl and she liked that in herself and she liked it in other people.”

Carly Simon and Jackie Onassis at Bunch of Grapes Bookstore on Martha's Vineyard, Mass on Sept. 2, 1989. Stephen Rose / Getty Images

Their story begins in 1983 at a restaurant called the Ocean Club on Martha’s Vineyard.

Simon was about 38 years old at the time and already a massive star. Her first hit single, “You’re So Vain,” was released 10 years earlier. Onassis, then 54, was working as an editor at the Doubleday publishing company. President John F. Kennedy had been assassinated 20 years earlier.

Onassis’ son, John Jr., spotted Simon in the restaurant. He walked over to Simon, whom he already knew, and asked if she wanted to meet his mom, who had recently moved to town.

“She would really like to meet you,” Simon remembers John Jr. saying to her.

“So I went over to their table and had a little bit of a sit-down with them,” Simon said. “And it wasn't long after that she called me and asked me if I would write a memoir.”

Simon told her she’d give it a try. But about 80 pages in, she scrapped the idea.

“My mother was still alive then. And the nucleus of the story was the story about my mother and her lover and my father,” Simon said. “And it was a very intimate story. It was filled with too many taboos. I stopped and I called her and said, ‘Would you mind if I wrote children's books instead?”

Onassis agreed, and Simon went on to write two children’s books for Doubleday. In the process, the pair developed a friendship that spanned the final 10 years of Onassis’ life.

Carly Simon at her home in Martha's Vineyard. Jake Whitman / NBC News

They went out to lunch and to the opera. They attended parties together and had frequent movie dates.

Whenever Simon showed up to a theater for one of their outings, she knew just where to find the famously-private Onassis.

“In the ladies room,” Simon said. “With her little Gucci shoes sticking out from underneath the” stalls.

In time, Onassis became a mother figure to Simon, giving her advice on everything from money to men.

“You’ve got to marry up,” Onassis would tell her, Simon said. “You’ve got to find somebody who's gonna make your lineage stronger, who's going to give you the best possible children, who's going to support you, who's going to have a great position in life in his workplace.”

Simon, whose first marriage to James Taylor ended in divorce, says she was more into artistic types.

“I don't think she thought marrying an artist was such a good idea,” Simon said. “And when I got married to Jim (Hart), my second husband, she at first was not in favor of that because Jim was not a provider in the sense that she thought women should have a provider as their husband.”

Carly Simon with Jacqueline Kennedy Onassis at a Labor Day party on the beach. Jake Whitman / NBC News

Simon said Onassis provided her with the kind of support and guidance that she didn’t always get from her own mother.

For example, Simon said that when she won the Academy Award for Best Original Song in 1988 — for “Let the River Run” in the film “Working Girl” — this was her mother’s response:

“She said, ‘Darling, that’s so fantastic, congratulations, but there are so many people who deserved it more, but you won,’” Simon recalled.

Onassis was different. “She was really interested in my life,” Simon said.

Simon also cherished their relationship for other reasons. Onassis, she said, spoke to her with a bracing honesty.

“She gave me advice like nobody else did,” Simon said. “Other people would be too nervous to tell me what they really thought about certain things ... But Jackie was forthright.”

Onassis was known to the outside world as a paragon of elegance and restraint. But the woman Simon knew had a playfulness and a practical joker mentality that played out in multiple ways.

"Live at Grand Central" is a 1995 concert Carly Simon gave in the middle of New York City's Grand Central Terminal. The LIFE Picture Collection via Getty Images

One day, Onassis went along with Simon to a recording session with the acclaimed opera singer Placido Domingo. Onassis watched as Simon and Domingo sang a song from Miss Saigon for his album, “The Broadway that I Love.”

“After we went home together and we talked about how wonderful the whole session was and how divine Placido is,” Simon said.

The next morning, Simon received a letter in the mail from Domingo. “Darling Carlita, please be my Valentine,” it said. “You are so lovely. I loved singing with you."

Inside was a signed cassette of his songs. Moments after she opened it, Simon phoned Onassis.

“To tell her that I'd gotten this letter from Placido,” Simon said.

After a long pause, Onassis said,“Carly, did you really think it was from Placido?"

Only then did Simon realize that Onassis had played a practical joke on her.

As their relationship evolved, Simon felt there were some topics that remained off-limits.

“I would never bring up JFK,” Simon said. “I would never bring up a lot of the subjects that we ended up talking about because she would bring them up. But there was a certain line that I couldn't cross, that I wouldn't cross, just out of being careful.”

But Onassis sometimes opened up to her — even about one of the most taboo subjects: JFK’s affairs.

“In a cheerful but resigned way, she told me that of course she knew about them,” Simon says in her book. “She just didn't mind their presence as much as she might have. Because she knew he loved her much, much more than any of his dalliances.”

Carly Simon's new memoir, "Touched By the Sun: My Friendship With Jackie." Jake Whitman / NBC News

But in the interview, Simon said it was clear that the friend she knew as Jackie was wounded by some of the president’s behavior.

“For instance, his not being there for the birth of a child, his being off with a mistress while she was in the hospital,” Simon said. “There are various things that he did that by comparison to having a mistress must have hurt more.”

Simon’s relationship with Onassis also yielded a fair share of awkward moments.

When Simon signed a deal with Onassis to write her first book, she was paid an advance of $25,000. When the pair discussed payment for her second book, Onassis asked her for the details of the first deal.

“And I said, ‘Well, I got $25,000,'’’ Simon said. “And she said, ‘Oh, Carly, you got screwed.’ So, so funny. I didn't have the heart to tell her that she had made the deal.”

During the period of their friendship, Simon said she had her own struggles. She said she developed a pill addiction and spent time at a rehab facility where she was allowed one call a day.

Simon always called the same person. “Jackie,” Simon said. “She was being the mother that I never had. And she was not judging me. She was just so supportive and funny at the same time.”

In April 1994, a family spokeswoman announced that Onassis had non-Hodgkin's lymphoma, a type of blood cancer. Crowds of people jammed the sidewalks outside her apartment the following month as word spread that she was in the last stages of her cancer battle.

Inside the home shortly before Onassis died, Simon was among the small group of people invited by the family to say goodbye, including John Jr. and Onassis' longtime companion, Maurice Tempelsman.

“I held her hand and told her I loved her,” Simon said. “John was standing at the end of her bed with his hands neatly folded and Maurice was there with his hands folded and they were both praying over her.”

“The record of the Gregorian chants was playing in the background,” Simon added. “And it was just one of those moments that you just can’t — I couldn't believe I was there — I couldn't believe that my friend was slipping away.”

Just before Onassis' death, Simon had written a song about her called “Touched by the Sun.” When Onassis was nearing the end of her life, she asked Simon to perform the song at Grand Central Terminal, a New York landmark Onassis helped save.

The surprise concert was held in April 1995.

Nearly 25 years later, Simon says she didn't tell Onassis’ only surviving child Caroline Kennedy that she was writing the book, but hopes Kennedy will “accept it in the spirit in which it was meant, which was with utter warmth.”

Simon said she knows writing about the notoriously private Onassis in such a personal way might draw criticism. But she sees it differently.

“On the other hand, objectively, she would have been very interested in herself,” Simon said. “And that goes along with her first mandate to me, which was to write a memoir about the interesting people that I knew.”

“What better answer,” Simon said, “than to write about Jackie?”