"After a great deal of thought and a lot of work on our relationship, we have made the decision to end our marriage," the pair tweeted.
They first met in the 1980s when Melinda joined Bill's Microsoft firm.
The billionaire couple have three children and jointly run the Bill & Melinda Gates Foundation.
The organisation has spent billions fighting causes such as infectious diseases and encouraging vaccinations in children.
The Gates - along with investor Warren Buffett - are behind the Giving Pledge, which calls on billionaires to commit to giving away the majority of their wealth to good causes.
Bill Gates is the fourth wealthiest person in the world, according to Forbes, and is worth $124bn (£89bn).
He made his money through the firm he co-founded in the 1970s, Microsoft, the world's biggest software company.
The pair both posted the statement announcing their divorce on Twitter.
"Over the last 27 years, we have raised three incredible children and built a foundation that works all over the world to enable all people to lead healthy, productive lives," it read.
"We continue to share a belief in that mission and will continue our work together at the foundation, but we no longer believe we can grow together as a couple in the next phase of our lives.
"We ask for space and privacy for our family as we begin to navigate this new life."
How did they get together?
Melinda, now 56, joined Microsoft as a product manager in 1987, and the two sat together at a business dinner that year in New York.
They began dating, but as Bill told a Netflix documentary: "We cared a lot for each other and there were only two possibilities: either, we were going to break up or we were going to get married."
Melinda said she found Bill - methodical it seems even in matters of the heart - writing a list on a whiteboard with the "pros and the cons of getting married".
They got married in 1994 on the Hawaiian island of Lanai, reportedly hiring all the local helicopters to stop unwanted guests flying over.
Bill, 65, stepped down from Microsoft's board last year to focus on his philanthropic activities.
What is the Gates Foundation?
- The couple established the Bill & Melinda Gates Foundation in 2000 in Seattle
- The foundation focuses primarily on public health, education and climate change
- Its grants included some $1.75bn to vaccine initiatives and research during the Covid-19 pandemic
- In 2019, the foundation had net assets of more than $43bn
- Bill and Melinda Gates pumped more than $36bn into the foundation between 1994 and 2018
Source: Reuters news agency
What role did Melinda play in their campaigning?
"Bill and I are equal partners," she told the Associated Press in an interview in 2019. "Men and women should be equal at work."
In her recent memoir The Moment of Lift, she wrote about her childhood, life and private struggles as the wife of a famous figure and and stay-at-home mother with three kids.
Working together at the foundation had made their relationship better, she argued. "He's had to learn how to be an equal, and I've had to learn how to step up and be an equal," she wrote.
Apart from her work with the foundation she founded Pivotal Ventures, an investment company focused on women and families, in 2015.
"The world is finally waking up to the fact that none of us can move forward when half of us are held back," she said at the time. "The data is clear: empowered women transform societies."