Unseeded Jelena Ostepanko of Latvia won the junior girls' title with a 2-6, 6-3, 6-0 win over eighth-seeded Kristina Schmiedlova of Slovakia.
"It was almost surreal, but hopefully it will kick in the next couple of days,'' Rubin said of his win over Kozlov.
Following the 2-hour, six-minute match, the two friends _ who often room together at tournaments -- ran around the court with an American flag that Kozlov's father had given to him in the morning.
Rubin had originally stopped playing junior tournaments after the 2013 U.S. Open. When he changed his mind, his junior ranking was so low -- and his ATP ranking -- that he had to play the qualifying tournaments at the French Open and Wimbledon.
Kozlov, who was also a finalist in the Australian Open boys' singles event in January, made too many mistakes at crucial times in the match.
"I kind of choked at 3-all in the third by giving away a service game I should've won and that was it, the end of the match,'' Kozlov said. "It's just been tough.''
In boys' doubles, No. 3-seeded Orlando Luz and Marcelo Zormann of Brazil beat top-seeded Kozlov and Andrey Rublev of Russia 6-4, 3-6, 8-6 in the title match.
Tami Grende of Indonesia and Yu Yequi of China won the girls' doubles title with a 6-2, 7-6 (5) win over Marie Bouzkova of Czech Republic and Dalma Galfi of Hungary.