The 27-year-old Kenyan hit the front with about 300m to go after compatriot Alfred Kipketer sprinted clear on the first lap of the race.
Rudisha finished in one minute 42.15 seconds, ahead of Algeria's Taoufik Makhloufi and fast-finishing American Clayton Murphy.
"I am so excited," said Rudisha. "It is the greatest moment of my career."
Makhloufi ran a new national record of one minute 42.61 seconds and Murphy clocked a personal best of one minute 42.93 seconds in a bizarre race.
Kipketer set out fast, going through the first 200m in just 23 seconds.
But the 19-year-old, who had beaten Rudisha in the Kenyan national trials, faded to finish seventh in Rio.
"Running 1:42, it's just fantastic," added Rudisha. "I had no doubts before. The feeling in my body was good. It is great to win such a big competition."
BBC Sport's chief sports writer Tom Fordyce in Rio:
"He is the greatest 800m runner of all time and he may also be the nicest man in his sport. Rudisha may not be at the same holy level as that unforgettable night in London, but he remains both a joy to watch and an unstoppable force.
"After the injuries he suffered after 2012 - missing the worlds in 2013, requiring a serious knee operation less than two years ago - this victory was never preordained. He just makes it look that way."
David Rudisha became the first athlete since New Zealand's Peter Snell in 1964 to retain the men's 800m Olympic title.