In statements posted to Instagram on Wednesday they each say that "after many meaningful and difficult conversations, we have made the decision to separate."
"As always we remain a close family with deep love and respect for each other and for everything we have built and will continue to build," they wrote.
"For the well-being of our children, we ask that you respect our and their privacy."
They will share custody of their three children, Xavier, 15, Ella-Grace, 14, and Hadrien, nine.
The Liberals confirmed Trudeau will continue to live at Rideau Cottage and the children will primarily live there. Grégoire Trudeau has moved to another home in Ottawa but will spend time at the cottage with her children, including during Trudeau's frequent travels.
The Prime Minister's Office said in a statement the couple have signed a separation agreement "to ensure that all legal and ethical steps with regards to their decision to separate have been taken, and will continue to do so moving forward."
The statement said Canadians can expect to still see the family together and that they will vacation together next week. They vacationed as a family together in Montana in April and in Jamaica over the Christmas holidays.
Grégoire Trudeau, however, has played a less-visible role in recent years, rarely travelling with the prime minister on official trips. They were seen together publicly at Canada Day events in Ottawa last month. She also made a public appearance in July.
Justin Trudeau and Sophie Grégoire Trudeau are separating after 18 years of marriage. #cdnpoli
Trudeau, 51, and Grégoire Trudeau, 48, were married May 28, 2005, at a ceremony in Montreal.
They first met as children when she was a classmate of his youngest brother, Michel, and reconnected as adults when they co-hosted a charity gala in 2003.
They initially lived in Montreal, where Xavier and Ella-Grace were born. They moved to Ottawa as a family in 2010, two years after he was elected MP for Papineau in Montreal.
Hadrien was born in Ottawa a year and a half before Trudeau became prime minister.
Grégoire Trudeau was a Quebec entertainment TV personality but stepped away from that career after their move to the national capital.
In his 2014 autobiography "Common Ground," which Trudeau dedicated to his wife as his "best friend, partner and soulmate," he spoke about his marriage, saying it had "difficult ups and downs" but that they were true partners.
"We are honest with each other, even when it hurts," he wrote.
They frequently expressed their love for one another on social media, including on their most recent wedding anniversary and on birthdays.
Trudeau is the second prime minister to announce a separation while in office.
His father, Pierre Trudeau, separated from wife Margaret in 1977 and the two divorced in 1984.
Kim Campbell was divorced before becoming prime minister in 1993.
Trudeau discussed being a child of divorce in his book, acknowledging it significantly affected his early life. He was five years old when his parents separated.
He said that divorce always has "casualties where children are involved" but credited his parents for doing their best to "minimize the pain and sense of loss."
He did acknowledge it affected his self-esteem but that his parents' efforts prevented "much of the emotional trauma that divorce can inflict on children."
In a YouTube video interview she did with The Sorry Girls alongside U.S. first lady Jill Biden in March, Grégoire Trudeau said she tries to make their home a place of safety for their kids.
"We have our struggles and we have our battles and I always remember that when tough times do come that we keep a sense of safety in the house from all fronts and that our kids, whatever room we find ourselves in, feel that there’s actually space to discuss real things,” she said.
This report by The Canadian Press was first published Aug. 2, 2023.
Note to readers: This is a corrected story. An earlier version said Pierre Trudeau and Margaret Trudeau separated in 1979.