By Caroline Stauffer

RIO DE JANEIRO (Reuters) - France won its second team show jumping gold medal ever and its first in 40 years on Wednesday in a dramatic final round of competition featuring eliminations, last-minute horse swaps and rails toppling down.

The United States took silver after Olympic veteran Beezie Madden withdrew due to an injured horse, meaning the United States started with only three riders and was not able to drop its worst score when Lucy Davis knocked a rail down for four penalties.

Germany claimed bronze after an adrenaline-filled jump off to break a tie with Canada. Daniel Deusser, the third of four Germans to jump, sealed the deal with a swift and clean round, sparing the final team member from jumping.

France ended the two rounds of competition with three penalties for exceeding time allowed, but being the only team to leave all the rails up was enough to win.

Germany, Brazil, the Netherlands and the United States were tied with no penalties going into the final round, though of the top teams only Germany had four riders still in the competition after withdrawals from the United States and the Netherlands and an elimination for Brazil due to rough riding.

"Today we had four teams coming in clear so the idea was to step up the degree of difficulty," said Brazilian course designer Guilherme Jorge. "We also played with time allowed ... The riders have to decide if they can afford a time fault."

The competition was not all smooth sailing for France, which had a last-minute substitution, pulling in reserve Philippe Rozier after Simon Delestre, the sport's No. 2 ranked rider, withdrew his horse due to an injury four days before competition began.

"To be sure we had really bad luck in the beginning of the week with Simon's horse... that helped us fight more," said French rider Kevin Staut.

France has marked a triumphant return to the top of equestrian sports in Rio, claiming gold in eventing last week as well as individual eventing silver. It last won show jumping team gold in Montreal in 1976.

Home-team favorites Brazil finished in fifth behind Canada after all three riders still in the competition had a single rail down.

Germany's seven-time Olympic veteran Ludger Beerbaum said the drama and uncertainty of the day's competition showed a proposed rule change that would require teams of three rather than four riders was a bad idea. Three-person teams would simplify competition, with no possibility of a dropped score or of surviving a withdrawal or elimination.

"The Olympics in Rio have proven that the format of four per team could not be better," he said. "For the drama of the sport we want this roller coaster."

Wednesday also served as a third qualifier for the individual medal round on Friday. Canada's Eric Lamaze is the only rider with no penalties going into the final ride.

(Reporting by Caroline Stauffer; Editing by Jan Harvey, Ken Ferris and Meredith Mazzilli)