Melo clipped a superb lob over the head of the top-seeded Bryans to level on sets, and the Brazilian player hit the winner with a neat volley to the side to prompt wild celebrations with Dodig, a Croatian.
''It's a great moment for both of us to win our first title, to beat the best team in the world and the best in history,'' Dodig said.
''Our main goal this season was to win a Slam. But I have to be honest, I didn't think it would happen here, as it's not our best surface. Suddenly, we have the trophy.''
It was their eighth match against the Bryans, a rivalry that started in 2012, and their third win. The Bryans denied them in the finals at 2013 Wimbledon and 2014 ATP Finals.
''I have been playing doubles (with Dodig) a long time and I told him we can do great things,'' Melo said. ''Now we are more than good friends, and we've won a Grand Slam title together.''
The Bryan twins were going after their 17th major title, and 107th career title. They also won at Roland Garros in 2003 and 2013.
After hitting the winner with a cross-court volley at the net, Melo sank to his knees and put his hands on his face in apparent disbelief.
In the Court Chatrier stands, three-time French Open champion Gustavo Kuerten of Brazil cheered enthusiastically and took photos of third-seeded Melo and Dodig as they celebrated.
Melo raised the trophy aloft as Kuerten - the singles champion here in 1997, 2000 and 2001 - patted him on the head.
''He gave me support during the week, and this tournament is special for Brazilians because of what he did here,'' Melo said. ''I didn't know he was so close to the court, sometimes between points he was talking to me. He's an inspiration.''