Nicolas Almagro squeezed through to the third round of the US Open after defeating Germany's Philipp Petzschner in a five set thriller on Thursday.