West Germany came within one victory of winning the Davis Cup today, thanks to the inspired play of Boris Becker, but Stefan Edberg ended the suspense, clinching the Cup for Sweden in the fifth match.

Edberg defeated Michael Westphal, 3-6, 7-5, 6-4, 6-3, after Becker had brought West Germany even by beating Mats Wilander, 6-3, 2-6, 6-3, 6-3. The result marked the first time since 1964, when Australia beat the United States, that a Davis Cup has hinged on the fifth and final match.

The outcome also marked the first time that a European team has won the Davis Cup in consecutive years since France did it in 1931-32.

In the deciding match today, Edberg started so badly against Westphal that the Swedes must have wished they'd played Joakim Nystrom, instead. Edberg, obviously nervous, could not return effectively against Westphal's hard, flat serve -- and Nystrom has perhaps the best return in tennis.

At the outset, Edberg's nerves disrupted his normally reliable serve. At 1-3, ad out, he hit a second serve into the middle of the net, a clear sign of edginess. For the Swedes, that set was lost with dismaying speed.

But Edberg gradually found his rhythm and with it his confidence, despite a roaring, foot-stamping crowd that took to clapping rhythmically after Westphal lost a point. Edberg had to struggle to even the match at a set each, but from that point he gradually took control.

As Hans Olssen, the Swedish team captain, put it: "He played better and better and better. And better." Each time Westphal appeared ready to break his serve, Edberg raised his game and held.

Faced with 0-40 at the start of the fourth set, he responded with five straight winners. Four games later, at 30-all, he again delivered four straight. At the end, he showed the quality of play that has lifted him to No. 5 in the world, hitting a succession of deep serves followed by decisive volleys.

Edberg was talking to himself at the end, and began pumping his fist after hitting winners, running back to the base line to start the next point. He won the match, and the Cup, with a serve that whistled into the forehand corner.

Westphal slapped at it, and the ball sailed long and wide.

"I wasn't playing that well," the soft-spoken Edberg said afterward, "but I never stopped fighting."

The team launched into song to accompany the champagne in its locker room. "For me, this was a bigger victory than beating the U.S. last year," said Olssen. "The boys proved they could defend the Cup, and they did it abroad."

West German fans had the consolation of seeing the 18-year-old Becker raised to a still-higher pedestal. Becker won both of his singles matches here, against players ranked above him, and he showed himself able to handle both the pressures of superhero status and the heat-of-battle frustrations that have sometimes undone him in difficult matches.

The Becker-Wilander match produced a curious reversal of player characteristics. The methodical Swede made as many errors as the mercurial West German, including bunches of them that eventually spelled defeat.

In all, Wilander failed to obey the first commandment of fast-court tennis: hit your serve hard and deep, and return the other guy's hard and low.

But Wilander's problems were much less his doing than Becker's. The West German's serve, always a fine weapon, became stronger as the match progressed. He served winner after winner deep into the forehand corners and his service games seldom went to deuce.

Surprisingly, Becker's ground game was nearly as effective as his serve. He made far fewer ground-stroke errors than usual, won more than his share of back-court rallies and varied the pace effectively.

Wilander refused to blame the fast court for his loss. "Obviously, Boris' big serve was an advantage here," he said. "But I think he could defeat me on any surface now."