The Australian duo came from a set down to win on Court Philippe Chatrier in just over two hours, emerging 6-7 (6-8) 7-6 (7-1) 10-8 victors at Roland-Garros.
Krajicek and Ram would start well, winning a break point in the sixth game, only for their Australian opponents to respond instantly to level the encounter at 4-4.
With both pairs holding their serve for the remainder, a tie-break would decide who would take the first set, with the Americans able to obtain the early advantage.
Krajicek and Ram found another early break in the second, but again saw their lead vanish as Ebden and Peers rallied to win three consecutive games.
The Australian's took the game to a second tie-break, producing some stunning tennis along the way as the encounter went the distance in the French capital.
Ebden and Peers would carry their momentum into the decider, and despite missing four gold medal points, were able to hold on to secure the triumph.
Data Debrief: Australia strike gold at Roland-Garros
Ebden and Peers showed grit and determination worthy of winning a gold medal, coming from a set down to scoop the top prize.
The Australian's impressed on serve, scoring nine aces compared to Krajicek and Ram's six, winning 73% of their first-serve points.
In what could be Nadal's final appearance at Roland-Garros, the American duo showed no mercy, prevailing in straight sets 6-2 6-4 to advance to the next round.
After beating Roman Safiullin to reach the quarter-finals of the singles earlier that day, Alcaraz started slowly as the Spanish pair found themselves immediately behind.
Nadal and Alcaraz would close the gap to 3-2, but their American opponents would continue their dominance, taking the next three games to see out the first set.
The Spaniards started much better in the second, with the pairs trading blows and each holding their own serve.
But the decisive break would come in the seventh game, with Krajicek and Ram going to within two games of producing an unlikely upset against the pre-tournament favourites.
The Spaniards then missed two break points to take the game to 5-5, with the Americans missing two match points of their own in a thrilling final set.
But it was Krajicek and Ram who would emerge victorious, dumping out Nadal in what may be his last dance on the court.
They will face Czech Republic duo Adam Pavlsek and Thomas Machac for a place in the final on Saturday.
Data Debrief: Nadalcaraz no match for American duo
The fairytale ending for Nadal has come to an end, but it took an impressive display from Krajicek and Ram to do so.
The Americans won 25 of their 57 return points compared to Nadal and Alcaraz's 19, and converted all three of their break points.