The two-time grand slam champion, whose ranking has dropped to a lowly 174, suffered a setback in his preparations for the US Open after losing 7-5 2-6 6-2 to Ram on Thursday.
Ram’s quarter-final will be against 19-year-old compatriot Ryan Harrison, who waited out an evening weather delay to beat Belgian Xavier Malisse, the No.4 seed, 6-7 (3-7) 6-4 6-4.
Mardy Fish opened his title defence with a comfortable 6-3 6-3 victory over France’s Nicolas Mahut that put the top-seeded American into the quarter-finals.
Fish, who enjoyed a first-round bye, fired six aces and broke Mahut four times to finish off the second-round clash in less than 90 minutes.
Fish showed no ill effects from an abdominal muscle strain which had bothered him since the French Open.
The world No.9 will play on Friday for a semi-final spot against Indian No.8 seed Somdev Devvarman, who booked his first quarter-final since late April with a 6-1 6-3 defeat of Japan’s Tatsuma Ito.