This article is from the Tolkien Newsgroups FAQ, by Steuard Jensen firstname.lastname@example.org with numerous contributions by others.
The Nazgul withdrew from Weathertop despite a five-against-one
fighting advantage and with the One Ring almost within their grasp.
Many share Aragorn's confusion about this: "I cannot think why they
have gone and do not attack again." There are many possible reasons,
and the true answer is likely to be a combination of them.
Most agree that Aragorn's analysis in "Flight to the Ford" is at
least in part accurate:
I don't think they expected to be resisted... They will come again
another night, if we cannot escape. They are only waiting, because
they think that their purpose is almost accomplished, and that the
Ring cannot fly much further.
Many see this explanation as inadequate: the Ring seems like too great
a prize for the Nazgul to take such foolish caution. Some quote Letter
#210 where Tolkien says that "They have no great physical power against
the fearless", arguing that Aragorn was able to drive the Nazgul away.
However, this quote does not preclude them from having "normal"
physical power, and the Witch King was willing to do battle with
skilled warriors at other times.
Some believe that Frodo's cry of "Elbereth" helped drive the Nazgul
away: after remarking that Frodo's sword had not harmed the Witch King,
Aragorn says, "More deadly to [the Witch King] was the name of
Elbereth." This idea is clearer in an early draft: in _The Return of
the Shadow_ ("At Rivendell"), a fragment includes Gandalf saying, "Not
to mention courage - and also swords and a strange and ancient name.
Later on I must be told about that curious sword of yours, and how you
knew the name of Elbereth." (Presumably Gandalf is discussing this
very question.) However, in the final text, it is Aragorn who comments
on the name, but he never used it himself. Because of this, some
interpret Aragorn's comment as nothing more than a statement of just
how ineffective Frodo's sword slash had been.
A final factor which some believe led the Nazgul to turn away was
Frodo's sword from the Barrow Downs. As discussed in question III.C.2,
many believe that the Nazgul were afraid of the barrow blades. The
description of the attack on Weathertop is at least consistent with
this theory: after Frodo put on the Ring, three of the wraiths
rushed towards him. Desperate, he drew his own sword, and it seemed
to him that it flickered red, as if it was a firebrand. Two of the
figures halted. The third... sprang forward and bore down on Frodo.
All of the wraiths seem to have left immediately after the Witch King
stabbed Frodo. As Frodo was seeing into the "wraith world" with the
Ring on, some read the description of his sword flickering red as an
indication that it had some overt magical power there.
On the other hand, the red flicker could have been just reflected
firelight, which often remained bright even to one wearing the Ring. In
fact, there is no clear evidence that the attack did not go just as the
Nazgul planned. Some also object that the Nazgul would not have feared
Frodo's sword because the Witch King was able to break it from a
distance in "Flight to the Ford". Others counter that such a spell may
have taken some time to prepare, and that Tolkien seems not to have
considered this a problem in the first draft of the text (when the
Nazgul's fear of the swords was explicit).