NEW YORK (AP) Mardy Fish's last U.S. Open memory will be of the Louis Armstrong Stadium crowd roaring for him.

Failing to serve out the match, his legs cramping badly at the end - those details are less important than the fact he was there, playing all out and pushing a top-20 player to the limit.

The 33-year-old American's career ended Wednesday in the second round with a five-set loss to 18th-seeded Feliciano Lopez. Before this year, he hadn't been back to the U.S. Open since 2012, when he never made it onto the court for what should have been one of his biggest matches. Fish withdrew that day because of a panic attack before his fourth-round meeting with Roger Federer.

He played little after that as he struggled with anxiety disorder, but Fish decided for one last hurrah this summer on the hard-court circuit, culminating with the U.S. Open. The former top-10 player hoped to make some new memories at Flushing Meadows and tell his story to help others coping with mental illness.

''I accomplished everything that I set out to this summer,'' Fish said, ''and I'm happy about that.''

His summer of tennis nearly stretched on at least two more days. Fish had a chance to serve out the match in the fourth set but made three straight unforced errors then double-faulted to be broken at love.

Fish said afterward the nerves weren't too bad.

''Didn't pick a great time to play the worst game I played all day,'' he said. ''I haven't been in that position in a long time, obviously. So things happen.''

Lopez quickly won the next two games as well to force the deciding set, and Fish's legs were already starting to cramp up. And yet he hung in there at the start of the fifth, when Lopez was the one who seemed overwhelmed by the moment.

He had four double-faults in the last set, but also seven aces to wiggle out of trouble.

''It's hard to play a guy that's sort of wounded,'' Fish said.

''I was sort of wondering if I could actually get through it,'' he added, ''but obviously I knew I was in a bit of trouble.''

His legs were cramping more and more and he was able to move less and less. Never did he consider quitting.

''You would have had to carry me off the court,'' Fish said. ''I was definitely not stopping at that point.''

Finally when he was serving at 3-4, his leg seized up in the middle of a point. Lopez broke then closed out the 2-6, 6-3, 1-6, 7-5, 6-3 victory after 3 hours, 11 minutes.

''That probably wouldn't have happened a few years ago. I probably would have been fine in the fifth set,'' Fish said. ''I worked as hard as I could. My body is just about done. So I gave it everything I had.

''That was all I had.''

During their handshake at the net, Lopez recalled afterward, he told his longtime rival ''that he deserved to win, that he was the better player today.''

Asked about that exchange later, Fish replied with a wry smile, ''I felt the same.''

''Those are the situations you work so hard to be in,'' he said. ''You know, just an awesome crowd, and it's a really nice memory to have on my final match. Obviously not the last set, but my final match.''

Lopez also is 33 and the two have now played nine times. The Spaniard called Fish ''a true gentleman.''

''He was a great player, had a good career,'' Lopez said in an on-court interview. ''It was very sad what was happening the last two, three years with this illness, and it's great to have him back at least for a few weeks.''

Fish carried his 19-month-old son into the interview room for his last U.S. Open news conference. He was feeling lousy physically, understandable for someone who hadn't played a 3-hour-plus match on a hot, humid day in years.

As well as he performed Wednesday, Fish never once reconsidered his retirement. He plans to play a lot of golf - he's a scratch golfer - and help out the U.S. Tennis Association.

''Just at peace personally,'' Fish said. ''I'm bummed that obviously my career didn't end the past few years the way I had imagined. But it is what it is, and you try to make the best of your situation.''