Thiago Pereira of Brazil took the silver and Kosuke Hagino of Japan won the bronze.
American Michael Phelps finished fourth, ending his streak of Olympic success that had seen him win a record eight gold medals in Beijing four years ago.
The medal for Lochte was the first gold captured by the United States in these Olympics.
LGBT community has 'bullied the American people': Bachmann
McPhee, Cokas 'working on their marriage' after affair