Australians Ebden and Peers win men's doubles gold at Paris Olympics
After dropping their first set of the week, the two 36-year-olds also trailed 4-2 in the second set but recovered the momentum to set up a super tiebreak.
The Australians moved 9-5 ahead but were pegged back to 9-8 before Peers produced an ice-cool volley after his serve and then pounded away a smash to seal victory.
It is only Australia's second Olympic tennis gold after Todd Woodbridge and Mark Woodforde won in Atlanta in 1996.
Peers added gold to the bronze he claimed in the mixed doubles alongside Ash Barty at the Tokyo Games.
"It was always going to be an absolute battle, it not it wasn't worthy of a gold-medal match," Peers, the 2017 Australian Open doubles champion, said.
"They were class the whole time and we needed to bring out best tennis.
"We hung around and managed to turn the tide."
The Americans, with 40-year-old Ram, one of three former doubles world number ones on court, showed his quality.
But he dropped serve at 4-3 in the second set and that proved a turning point in the match as the Australians raced through the second-set tiebreak to set up a decider.
A remarkable pick-up by Peers saw the Australian almost end up in the front row of Court Phillipe Chatrier and Krajicek then sent a smash wide to make it 7-2 in the first-to-10 decider.
The U.S. pair saved three match points to leave Peers with a serve for gold. With his daughter crossing her fingers in stands, he finished the job to start the Australian party.
"It's never easy to hold yourself together in those moments," Ebden said.
Americans Taylor Fritz and Tommy Paul also finished on the podium, earning the bronze by beating Czech duo Tomas Machac and Adam Pavlasek 6-3 6-4.