The American reeled in the 'Iron Lady' from Hungary in the last 50 metres, the pair swimming neck and neck in adjacent lanes before DiRado touched first to win by six-hundredths of a second.
Canada's Hilary Caldwell won bronze.
For DiRado, who is leaving the sport to take up a job in management consultancy, it was the perfect way to exit after a week in which she has now won two gold medals, one silver and one bronze.
"It's indescribable. That is just pure joy and surprise and excitement," she said. "That was my last race ever and I just won a gold medal."
"I read through, like, how to do expense reports, which was nice to kind of take my mind off the final tonight."
Hosszu blamed her loss on a poor final touch but said she was pleased with her week's work, having won three golds after leaving with no medals at all from three previous Olympics.
"I haven't been on the podium before, and I was able to be on the podium four times and three times on top, so I don't think I could have done any better," she said.
Hosszu had led from the start, reacting fastest from the block, but DiRado shadowed her the whole way, drawing level in the last 25 metres and then touching first in two minutes, 5.99 seconds.
Hosszu had already won the 100 backstroke and the 200 and 400 individual medleys in Rio, breaking the world record in the latter. DiRado added to her gold in the 4x200 freestyle relay, silver in the 400 individual medley and bronze in the 200 IM.