In a heated rematch of the 2008 Olympics bronze medal match, Montenegro pulled ahead 11-8 in the fourth quarter before Serbia got one goal from Slobodan Nikic and two more from Filip Filipovic to level with just over 90 seconds to play.
Udovicic then flipped in a pass from Filipovic with 55 seconds to go, and Serbia held on after Montenegro rattled the post twice in the closing seconds.
"I think this was not even a match, this was a war, a fight between two countries, and we succeeded in taking the great win in the end," said Filipovic, who scored three goals in the match.
Serbia and Montenegro won silver in water polo as one nation at the 2004 Olympics, two years before they separated. Since then, Serbia has come out on top against its smaller neighbour in the sport's marquee events, beating them at the 2008 games for bronze, in the 2012 European championship final and now here in London again for Olympic bronze.
The matches between the one-time compatriots are always bruising affairs, and Sunday was no different. Tempers flared throughout, with players wrestling each other for position in front of goal and the occasional smack to the face and elbow to the neck.
In the end, the officials handed out red cards to Serbia's head and assistant coaches, as well as two Serb players and one Montenegro player.
"This is not a usual match for us, this is something more, a step ahead with more emotions. We take all of our heart and put it into the game," Filipovic said. "You saw it in the end. It was not easy for us. I think that power, physical power, mental power, is not enough to win this game."
Losing a three-goal lead in the final quarter made the loss all the more crushing for Montenegro, which is still searching for its first Olympic water polo medal as an independent nation.
"We are disappointed in the end, especially because we were three goals better than Serbia before the end," Montenegro goalkeeper Milos Scepanovic said. "I think that it's a question of concentration and nerves on our side, and also on the side of Serbia's players. But they played better in that atmosphere, and they won, that's it."
Serbia has won nearly everything since the Beijing games, and with 2010 world player of the year Udovicic and 2011 world player of the year Filipovic, the team came into the Olympics as the gold medal-favourite.
The Serbs appeared to be on their way to the title until they was upset by the 2011 world champion Italians in the semifinal.
Despite falling two steps short of its goal, Filipovic said that after the disappointment of the semifinal loss, the team was just happy not to be heading home empty-handed.
"I think this bronze medal is more shiny for us than even if we get into the final and lose," he said. "This is very important for our country. We are a small country and we need to appreciate these medals."