Media playback is not supported on this device
Ellis and Langridge beat the world number five pair 21-18 19-21 21-10.
The pair performed above their world ranking of 22nd to reach Tuesday's semi-final, losing to fourth seeds Fu Haifeng and Zhang Nan of China.
Langridge said: "When we got to 14-7 in the last game, I thought: 'We might win this! We are going to win this!'"
He added: "Luckily Marcus was quite calm, which helped a lot."
In a dramatic finale, a review on the final point was required to seal the victory.
"I can't even describe how I felt after we saw that," said Ellis.
"This is an incredible feeling. After how we performed in our very first match, we knew we could compete with anybody."
Team GB have now won 52 medals in Rio.
Olympic silver medallist Gail Emms immediately tweeted her congratulations to the pair.
Find out how to get into badminton with our special guide.
Subscribe to the BBC Sport newsletter to get our pick of news, features and video sent to your inbox.
Marcus Ellis and Chris Langridge won Great Britain's first Olympic badminton men's doubles medal, beating China's Hong Wei and Chai Biao to take bronze.