
81 Wn.2d 863 (1973)
505 P.2d 790
ROBERT W. ANDERSON, Plaintiff,
v.
GOLD SEAL VINEYARDS, INC., Appellant, SPARKLETOP CORPORATION, Respondent and Cross-appellant, NAPCO CORPORATION, Respondent.
No. 42471.
The Supreme Court of Washington, En Banc.
January 25, 1973.
*864 Detels, Draper & Marinkovich and Frank W. Draper, for appellant.
Reed, McClure, Moceri & Thonn, P.S., by William R. Hickman, for respondent and cross-appellant.
Wolf, Hackett, Beecher & Hart, by James M. Beecher, for respondent.
ROSELLINI, J.
This appeal brings to the court questions concerning the allowance of costs under the "long-arm statute," RCW 4.28.185, which provides in paragraph (5):
In the event the defendant is personally served outside the state on causes of action enumerated in this section, and prevails in the action, there may be taxed and allowed to the defendant as part of the costs of defending the action a reasonable amount to be fixed by the court as attorneys' fees.
The plaintiff, Andersen, was injured when he was struck in the eye by a plastic stopper which flew off a bottle of sparkling wine while he was in the process of opening the bottle. The wine was bottled by the defendant, Gold Seal Vineyards, Inc., which will be referred to herein as Gold Seal. Gold Seal brought an indemnity action against the supplier of the stopper, Sparkletop Corporation, to be referred to herein as Sparkletop. Sparkletop answered the complaint in that third-party action, denying the allegations generally and affirmatively alleging contributory negligence on the part of Gold Seal. It also brought an indemnity action against the manufacturer of the stopper, Napco Corporation, to be referred to herein as Napco. Napco filed a responsive pleading generally denying the allegations of Sparkletop's third-party complaint.
All of these actions were consolidated for trial. Other pleadings were filed, but none of them affects the disposition of the questions before the court on this appeal.
After the trial had been in progress several days, Gold Seal moved for a voluntary nonsuit of its third-party complaint *865 against Sparkletop. Sparkletop then moved for a voluntary nonsuit of its third-party complaint against Napco. The motions were granted without argument or comment.
At the conclusion of the trial, judgment was entered on a verdict in favor of the plaintiff, against the only defendant remaining in the action, Gold Seal. Gold Seal satisfied the judgment. Thereafter, the trial court awarded costs and attorneys' fees to Napco, in the third-party action brought by Sparkletop, in the amount of $2,882.38. It also awarded costs and attorneys' fees to Sparkletop, in the third-party action brought by Gold Seal, in the amount of $5,501.57. Included in this sum was the amount of the judgment for attorneys' fees and costs which Napco had been awarded against Sparkletop.
Gold Seal and Sparkletop have appealed from the judgments entered against them. However, Sparkletop's appeal is contingent upon the court's holding in favor of Gold Seal. Primarily, it seeks to sustain the judgment.
[1] It is first contended that the court erred in awarding any costs or attorneys' fees under the long-arm statute, since, it is claimed, Sparkletop did not prevail in the third-party action which was brought against it, and Napco did not prevail in the third-party action in which it was named defendant. The theory advanced is that there can be no prevailing party unless an affirmative judgment is entered.
The prevailing party in a lawsuit is that party in whose favor judgment is entered. As a general rule where a plaintiff voluntarily dismisses his action, the defendant is entitled to costs. 20 C.J.S. Costs § 68 (1940); 20 Am.Jur.2d Costs § 18 (1965). See also Voluntary Dismissal  Conditions, Annot., 21 A.L.R.2d 627 (1952). This court has said, by dictum, that the awarding of costs to the defendant, where there is a voluntary nonsuit, is within the discretion of the trial court. In re Estate of Frye, 198 Wash. 406, 88 P.2d 576 (1939).[1] It would seem to follow that, if the defendant is awarded costs, he is the prevailing party.
*866 While we find no case in which this court has been asked to decide whether the defendant "prevails" when an action against him is dismissed on motion of the plaintiff, we have recognized that, where no judgment is entered against a defendant in an action at law, he is entitled to his costs. Sibbald v. Chehalis Sav. & Loan Ass'n, 6 Wn.2d 203, 107 P.2d 333 (1940). It also was said in that case that if the action is one of equitable cognizance, the disposition of the costs is within the discretion of the trial court and will not be disturbed in the absence of abuse.
Gold Seal cites Ennis v. Ring, 56 Wn.2d 465, 473, 341 P.2d 885 (1959), for the proposition that there can be no prevailing party unless an affirmative judgment is entered. That was a suit by a lessor for rent due, in which the lessee counterclaimed for wrongful leasing of part of the demised premises to a third party. This court held that the lessees had established sufficient damages to offset the plaintiff's claim for rent, and that neither party was entitled to costs.
We said:
The statute provides that the prevailing party is entitled to costs in the superior court. RCW 4.84.030. The prevailing party is the one who has an affirmative judgment rendered in his favor at the conclusion of the entire case. Snider v. Wright, 112 Wash. 536, 192 Pac. 923 (1920).
Snider v. Wright, 112 Wash. 536, 192 P. 923 (1920), the one authority cited in that opinion, was also a case in which the defendant filed a cross complaint. The amount of damages allowed the plaintiff, was in excess of those allowed the defendant, however, and this court applied the rule that the party in whose favor an affirmative judgment is entered is entitled to costs. See also Basse v. Kamholz, 65 Wn.2d 369, 397 P.2d 420 (1964); Nowogroski v. Southworth, *867 100 Wash. 336, 170 P. 1011 (1918); and Empire State Sur. Co. v. Moran Bros. Co., 71 Wash. 171, 127 P. 1104 (1912).
The rule stated in these cases is correctly applied where the defendant has obtained judgment upon a cross complaint, but it does not answer the question: Who is the prevailing party where no affirmative judgment is entered? We did not state in any of those cases and it is not the law that there can be no prevailing party unless such a judgment is entered.
We have said that a defendant who obtains a judgment setting aside the verdict in favor of the plaintiff and granting a new trial is the prevailing party and entitled to costs, even though the plaintiff again obtains a verdict in the second trial. Klock Produce Co. v. Diamond Ice & Storage Co., 98 Wash. 676, 168 P. 476 (1917); Briglio v. Holt & Jeffery, 91 Wash. 644, 645, 158 P. 347 (1916). We said in the latter case, "Costs follow as an incident to a judgment." This statement is in harmony with the definitions found in Black's Law Dictionary 1352 (rev. 4th ed. 1968), which cites the case of Klock Produce Co. v. Diamond Ice & Storage Co., supra, as illustrative of the rule stated there, that to be the prevailing party
does not depend upon the degree of success at different stages of the suit, but whether, at the end of the suit, or other proceeding, the party who has made a claim against the other, has successfully maintained it.
For this rule, the dictionary cites Bangor & P.R.R. v. Chamberlain, 60 Me. 285 (1872).
6 J. Moore, Federal Practice ¶ 54.70[4], at 1306 (1966, Supp. 1967), states the rule to be that where there is a dismissal of an action, even where such dismissal is voluntary and without prejudice, the defendant is the prevailing party, noting that it may be otherwise if the dismissal results from a settlement of the plaintiff's claim before trial. Under our decision in Thurston County v. Scammell, 7 Wash. 94, 34 P. 470 (1893), there also is an exception to the rule where the court loses jurisdiction after an action is *868 brought. Whether that exception should apply in cases where service was obtained under the long-arm statute, we need not and do not decide at this time.
We think the general rule pertaining to voluntary nonsuits, that the defendant is regarded as having prevailed, should be applied to cases in which service upon the defendant was obtained under RCW 4.28.185(5). Since that statute was enacted to facilitate service upon out-of-state defendants, the legislature must naturally have had in mind that a defendant who "prevails" is ordinarily one against whom no affirmative judgment is entered. When an action against such a defendant is dismissed, even though that dismissal be upon the motion of the plaintiff, the judgment which is entered shows that the plaintiff failed to prove his claim. We think it was the legislative intent that, at such a point, a defendant who has been served outside this state and has been put to expense in answering the complaint and preparing for trial should be reimbursed by the plaintiff if the court finds that the justice of the case requires it.
In this case, not only did the defendants in the indemnity actions expend funds in preparation for trial, but they were put to the further expense of participation in the trial itself for several days before the motion was made to dismiss. The legislature must have had in mind situations such as this, as well as those in which the defendant might prevail on the merits, when it provided for the taxing and allowance of costs, including attorneys' fees, in the court's discretion, in cases where the foreign defendant prevails.
We hold that the trial court was authorized by RCW 4.28.185(5) to award costs and attorneys' fees to the defendants in both indemnity actions, when they were dismissed on motion of the plaintiffs. There is no contention that the amount of the attorneys' fees awarded was unreasonable. The judgment, insofar as it awarded costs of defense and reasonable attorneys' fees to Sparkletop and to Napco, was within the proper exercise of the court's discretion, and no abuse of that discretion has been shown.
*869 [2] We are of the opinion, however, that the court erroneously included, as a cost of defense of Gold Seal's indemnity action against Sparkletop, Napco's costs of defending the indemnity action brought against it by Sparkletop, which Sparkletop was required to pay under the court's order.
Gold Seal correctly points out that it is no defense to an action to say that a third party may be obliged to indemnify the defendant if judgment is entered against him. Neither Gold Seal nor Sparkletop could have escaped liability merely by proving that others owed them a duty of indemnity; and the joining of the indemnity actions with the main action was a matter of convenience, not of necessity, as the voluntary dismissal of Gold Seal's indemnity action against Sparkletop, prior to the submission of the case to the jury, amply demonstrates.
Sparkletop's alleged right of indemnity against its manufacturer, Napco, was of no concern to Gold Seal. Gold Seal's right of indemnity against Sparkletop was based upon contract, express or implied, and the fact that Sparkletop might, in turn, have a contractual right against a third person did not relieve it of any duty that it might have to Gold Seal. Consequently, the cost of prosecuting an action against such an indemnitor was not a cost of defending Gold Seal's indemnity suit.
Apart from the sums allowable and taxed as costs, attorneys' fees and other items of expense in the preparation of a case for trial are allowed only where there is an agreement of the parties or by virtue of specific authority. Rocky Mountain Fire & Cas. Co. v. Rose, 62 Wn.2d 896, 385 P.2d 45 (1963); State ex rel. Macri v. Bremerton, 8 Wn.2d 93, 111 P.2d 612 (1941); 20 C.J.S. Costs § 218 (1940); 20 Am.Jur.2d Costs § 72 (1965).
Sparkletop maintains that it was entitled to be reimbursed by Gold Seal for Napco's costs which it was required to pay because its indemnity action would not have been instituted against Napco had not Gold Seal filed an action against Sparkletop. In other words, its theory is that *870 it is entitled to be compensated for any expenses which it may have incurred as a result of Gold Seal's bringing a suit against it. We can find no authority, in the statute or in our cases, for such a proposition. The statute provides for the awarding of costs of defense. Since there is no provision for reimbursement of expenses incurred by the defendant in prosecuting actions against other parties, such litigation must be undertaken at the defendant's own risk.
In bringing its indemnity action against Sparkletop, Gold Seal ran the risk of having to pay the costs and reasonable attorneys' fees of the latter if it failed, for any reason, to prove its claim against it. Gold Seal would have had to pay those costs and fees even though it had successfully defended the personal injury suit. While prevailing in the main action, it would have lost the indemnity action, for, having suffered no damage, it would have had no claim against Sparkletop. Sparkletop in turn took similar risks in bringing a third-party action against Napco, before its own liability had been established. It must bear the loss resulting from its voluntary action in bringing that suit.
Our research has disclosed only one case dealing with a closely analogous situation. In Tejas Dev. Co. v. McGough Bros., 167 F.2d 268, 269 (5th Cir.1948), the defendant brought third parties into the case by third-party proceedings claiming that they were liable to indemnify the defendant if the plaintiffs established their claims against the defendant. Judgment for the plaintiffs was reversed on appeal, thereby relieving the third parties of any liability. It was held that the plaintiffs were liable for costs relating to their controversy with the defendant and the defendant was liable for costs relating to the third-party controversy. The awarding of costs was, under the Federal Rules of Civil Procedure, discretionary with the court, as it is here. The court said:
Third party proceedings are permitted but not required by Rule of Civil Procedure 14. [Cf. CR 14.] Here they served a useful purpose to bind Bate et al. by the result of the litigation with McGough Brothers. It would have *871 complicated matters less if in the trial the whole third party controversy had been severed and an adjudication of it deferred until it was finally settled whether or not there is liability to McGough Brothers. In pressing their third party claims as and when they did the third party plaintiffs took the risk and must bear the consequences of futile costs. Certainly McGough Brothers [plaintiffs] ought not to bear costs in a controversy in which they had no part and which they did not cause.
See also A.T. Smith & Sons v. N.P. Van Valkenburgh Co., 337 F.2d 702, 705 (9th Cir.1964), citing Tejas Dev. Co. v. McGough Bros., supra, and applying the principle laid down there that the costs of the primary action should be distinguished from the costs of the third-party action. The case is also cited in 6 J. Moore, Federal Practice ¶ 54.70[4], at 1307 (1966), for the rule that a third-party defendant who has been impleaded by the original defendant may recover costs against the original defendant if the reversal of a judgment for the plaintiff releases the impleaded defendant from liability.
Thus, insofar as we have been able to determine, wherever the question has been raised, the courts have held that the defendant who voluntarily brings a third-party action for indemnity must bear the cost if the third party prevails, and cannot look to the plaintiff for reimbursement.
It is not claimed that the court allowed Sparkletop to include in its costs of defense of the Gold Seal indemnity action costs which it incurred in prosecuting the third-party action against Napco, aside from Napco's own costs of defending that action, which Sparkletop was required to pay. We assume, therefore, that, apart from the latter costs, those which were allowed were costs which Sparkletop showed, to the court's satisfaction, that it had incurred in defending the Gold Seal action.
Finding no authority for the trial court's action in imposing upon Gold Seal liability for the costs and attorneys' fees which Napco incurred in defending the action brought against it by Sparkletop, we hold that that portion of the *872 judgment against Gold Seal which reflects these costs must be stricken. As thus modified, the judgment is affirmed.
HALE, C.J., FINLEY, HUNTER, HAMILTON, STAFFORD, WRIGHT, and UTTER, JJ., concur.
NOTES
[1]  Upon related questions, see Thorndike v. Thorndike, 1 Wash. Terr. 175 (1861), holding that a husband was required to pay his wife's costs and attorney's fees when he voluntarily dismissed his divorce suit; Van Alstine v. Gray, 71 Wash. 607, 129 P. 106 (1913), holding that a trial court has discretion to refuse to award costs to either party, where, after a trial on the merits, it dismisses an action as having been prematurely brought; and Thurston County v. Scammell, 7 Wash. 94, 34 P. 470 (1893), holding that when a case is dismissed because the statute upon which it is founded has been repealed during the pendency of the action, the court has no power to award costs.
