The Czech Republic won the Davis Cup for the first time as an independent nation on Sunday, beating Spain 3-2 in the final after Radek Stepanek upset Nicolas Almagro in the last reverse singles.

The 37th-ranked Stepanek beat his 11th-ranked opponent 6-4, 7-6 (0), 3-6, 6-3, converting his second match point to send the 14,500 fans at the O2 Arena into wild celebration as they blew trumpets and beat their drums.

Stepanek dropped to the court in disbelief before teammates Tomas Berdych, Lukas Rosol, Ivo Minar and captain Jaroslav Navratil jumped on him.

""Davis Cup champions! That's amazing," Stepanek said. "We made history today and I hope the entire nation will be celebrating with us."

The victory means the Czechs completed a rare double just two weeks after the women secured the Fed Cup title in the same arena. No country has won both competitions in the same year since the United States in 1990.

"There's nothing more to achieve," Berdych said. "I have nothing to say more. This is a moment we never forget."

The Czechs' only previous victory came in 1980 as Czechoslovakia, which split in 1993, with a team led by Ivan Lendl.

"They've been our inspiration, our idols. They're the legends and now we're joining them," Stepanek said.

It was a sweet revenge for the Czechs after they were swept 5-0 by Spain in the 2009 final at Barcelona, with Stepanek losing to David Ferrer in five sets.

"We're sad at this moment," Ferrer said. "I'm very proud of our team. We were fighting to win here in Prague."

This weekend, Stepanek had three tough matches. He lost to Ferrer in straight sets in the opening singles Friday, but teamed up with Berdych to win the doubles Saturday.

Stepanek clinched the first set with a volley at the net. He wasted three breakpoints in the second game of the second set and was broken in the fifth, drawing level when Almagro dropped serve three games later.

At 5-4, Stepanek pumped his fist after a backhand passing shot gave him set point. But Almagro held and saved another set point in the game and two others in the 11th to force a tiebreaker.

Acrobatic volley

Stepanek looked in pain, possibly due to a knee problem after an acrobatic volley winner at the net in the tiebreaker. However, no treatment was needed and Stepanek took it easily 7-0 with a backhand winner.

Momentum ebbed and flowed in the third and fourth sets but Stepanek ultimately improved to 3-1 against Almagro, helped by the Spaniard's 56 unforced errors.

"I was playing very aggressive today; I wanted be the one who is active, who is controlling the game," Stepanek said. "It paid off, even though I lost the third set. I had no doubt I was on the way."

Playing in his first final, Almagro said he learned a lot despite losing to Stepanek and Berdych.

"It was a fantastic experience," Almagro said. "It's a pleasure for me to be part of the team."

Earlier Sunday, Ferrer kept alive Spain's hopes of winning a fourth Davis Cup title in five years by beating Berdych 6-2, 6-3, 7-5 in the first reverse singles match to level the final at 2-2.

Ferrer is wrapping up the best season of his career with a tour-best seven tournament titles. He converted his first match point for his 76th win of the year when Berdych's forehand hit the net, bringing cheers from the boisterous section of Spanish fans.

"I was always a few steps behind him," said Berdych, who had been undefeated in the Davis Cup this year. "He was just playing too good today."

Berdych spent more than seven hours on the court in the previous two days to win both his opening singles and the doubles, and it looked like fatigue may have finally set in at the end of the long season.

"I was feeling really well," he said. "That was definitely not an issue."

The Czechs beat Italy, Serbia at home and triumphed at Argentina in the semifinals en route to the final. Spain, without the injured Rafael Nadal, had been looking for its sixth title.