The 11th-seeded Spaniard won 7-6 (3), 6-7 (4), 7-6 (2), 6-1 on Saturday to reach the round of 16 at Flushing Meadows for the first time.
The 19-year-old Sock, ranked 243rd, got in on a wild card and made his first Grand Slam third-round appearance. He converted just one of 11 break points, while Almagro was four for five _ three of the breaks coming in the final set.
In the two tiebreakers Almagro won, he had no unforced errors while Sock had six. While the winners were almost even for the match _ 56 for Sock, 53 for Almagro _ Sock had 52 unforced errors overall to 24 by Almagro.