The Ukrainian crew of Kateryna Tarasenko, Nataliya Dovgodko, Anastasia Kozhenkova and Yana Dementieva crossed in a time of 6 minutes, 35.93 seconds to justify their status as narrow favourites, having won all three World Cup regattas this year.
The Germans won silver, 2.16 seconds behind Ukraine. United States took bronze in 6:40.63.
It was Ukraine's second gold of the London Games, taking the country's overall medal haul to four, and only their third rowing medal in its history.
Germany failed to win gold in the event for only the second time since the discipline was added to the Olympic rowing schedule in 1988.
An experienced American boat, which needed to come through a repechage to reach the final, was neck and neck with the Germans until the last 500 metres when they started to tail off.