And the fourth seeds got the early break to take a 4-2 lead in the first set, before losing it immediately with a double fault on break point.
The tiebreak was inevitable, albeit interrupted briefly when the Australian pair disagreed that the Ram serve to take the Americans to a 4-1 lead was good.
And the feistiness of the Aussies continued as they saved two set points, but with a wild shot up the line they could not save the third on their own second serve as Ram and Krajicek sealed the breaker 8-6 in a set that took six minutes under an hour.
The Americans made their move swiftly in set two as well, breaking in the third game, but once again the Australians hit back, targeting the Ram serve to level up at 4-4.
Ebden and Peers were urging the crowd to get behind them, and this surge of a comeback certainly inspired some more cheers from the neutrals as they held to edge ahead 5-4.
And with the next three games going with serve, it was down to another tiebreak, but this time the Australians were unstoppable, taking it 7-1 to force a match tiebreak.
And their momentum carried them through, with Krajicek getting so frustrated with his own errant shots that he hurled his racquet to the ground. Peers, meanwhile, was sliding brilliantly on the clay, racing almost to the front row of the stand and then back to the centre of the court to completely confound the Americans.
However, Ram and Krajicek did not make it easy for them, saving three gold medal points before the Australians wrapped it up on their serve.
Ebden and Peers were only the second Australian pairing to reach a men’s doubles final since tennis returned to the Seoul 1988 Olympics, following the success of Todd Woodbridge and Mark Woodforde, who won gold at Atlanta 1996 and silver at Sydney 2000.
This is Peers’s second Olympic medal after winning bronze alongside Ash Barty in the mixed doubles at Tokyo last time out.