It gave him a narrow a 114-114 115-113 115-113 majority decision to edge a contest in which both men were cut and where each showed why they are among the finest practitioners in the sport.
Golovkin, whose first defeat comes in his 40th bout - left the ring immediately without conducting an interview as his rival - fighting for the first time since serving a six-month drugs ban - celebrated.
"My corner told me that I needed to win the final round and that what's I did. I'm very emotional," said Alvarez, who has previously held world titles at middleweight and light-middleweight.
Golovkin told reporters afterwards: "I'm not going to say who won tonight, because the victory belongs to Canelo according to the judges. I thought I fought better than he did. We would like to have a third fight, we will negotiate that, that's what we want."