Not even some late heroics — some very, very late ones — were enough to keep the United States from being eliminated from the Davis Cup Finals on Thursday.

The U.S. failed to advance despite beating Italy 2-1 after a doubles match that ended past 4 a.m. local time in Madrid, the second latest finish in tennis history.

Sam Querrey and Jack Sock won the decisive doubles match 7-6 (4), 6-7 (2), 6-4 against Simone Bolelli and Fabio Fognini, but it wasn’t enough to secure the Americans in the quarterfinals as one of the two-best second-place finishers from the six groups.

Only a big win against Italy, without losing many sets or games, would have been enough to send the U.S. to the knockout stage of the revamped team competition.

With the elimination, the U.S. will equal its longest gap between Davis Cup titles, with its last one coming in 2007.

The doubles match ended 4:04 a.m. in the Spanish capital (10:04 p.m. ET, 0304 GMT), the latest finish in U.S. Davis Cup history and second in tennis history behind Lleyton Hewitt’s victory over Marcos Baghdatis at the 2008 Australian Open, which ended past 4:30 a.m. local time.

“I don’t even know where we are, what time it is, what day it is,” U.S. team captain Mardy Fish said. “That was pretty special from these guys, for sure.”

Taylor Fritz had kept the U.S. hopes alive by defeating Matteo Berrettini 5-7, 7-6 (5), 6-2 to level the series at 1-1 after Fognini had beaten Reilly Opelka 6-4, 6-7 (4), 6-3 to put Italy ahead.

“I’m excited for Taylor,” Fish said. “That’s one of the biggest wins of his life. I’m just happy to be part of it.”

The American team lost to Canada in its opening series on Tuesday — its first Davis Cup defeat against the North American neighbors. Italy also lost to the Canadians, who won the group and will face Australia in Thursday’s quarterfinal.

The U.S. sent to Madrid its youngest Davis Cup team in a decade, with 22-year-olds Fritz and Opelka making their tournament debuts. Fritz was the team’s highest-ranked player at No. 32.

The new Davis Cup is being played in a World Cup-style format with all 18 teams playing in a single venue in the same week, instead of the head-to-head confrontations that used to take place at varied sites over four weekends throughout the year.