
118 Cal.Rptr.2d 803 (2002)
97 Cal.App.4th 949
Thomas BANKS et al., Plaintiffs and Appellants,
v.
HATHAWAY, PERRETT, WEBSTER, POWERS & CHRISMAN et al., Defendants and Appellants.
No. B148305.
Court of Appeal, Second District, Division Six.
April 7, 2002.
*804 Hathaway, Perrett, Webster, Powers Chrisman & Gutierrez, Paul D. Powers, for Defendants and Appellants.
No appearance for Plaintiffs and Appellants.
YEGAN, J.
James C. Van Trees, III and his attorneys, Hathaway, Perrett, Webster, Powers & Chrisman and Greg W. Jones, (collectively "Van Trees") appeal from an order vacating an award for sanctions. The trial court ruled that it lacked jurisdiction to award sanctions pursuant to Code of Civil Procedure section 128.7 after a demurrer was sustained without leave to amend, but before entry of judgment.[1] We reverse.

Facts and Procedural History
On April 21, 2000, Thomas Banks and TB Properties (Banks) sued Van Trees for abuse of process, malicious prosecution and infliction of emotional distress. The complaint alleged that Van Trees wrongfully levied on a judgment after Banks satisfied a prior judgment in full.
On June 1, 2000, Van Trees served a motion to dismiss the action as frivolous and for monetary sanctions. The motion was based on section 128.7, subdivision (c)(1), which required that Van Trees wait 30 days before filing the motion with the trial court.
Van Trees also demurred to the complaint. The hearing on the demurrer was continued at Banks' request and taken off calendar after Banks filed a first amended complaint.
Van Trees demurred again and continued the hearing to accommodate Banks. Banks filed no opposition. The trial court sustained the demurrer without leave to amend on September 11, 2000.
Van Trees filed and again served the motion for sanctions two days after the ruling on the demurrer. The trial court *805 granted the motion on October 11, 2000, dismissed the complaint, and ordered Bank's attorney, Peter R. diDonato, to pay sanctions in an amount to be determined at a later date.
Banks moved for new trial, contending that the trial court lacked jurisdiction to award sanctions after it sustained the demurrer without leave to amend. The motion for new trial was heard in conjunction with Van Trees' motion to determine monetary sanctions. As a defensive measure, Van Trees filed an alternative motion to dismiss the action (§ 581, subd. (f)(1)), to be considered only if the trial court vacated the October 11, 2000 sanctions order.
The trial court, on its own motion, vacated the October 11, 2000 sanctions order and entered a dismissal based on the September 11, 2000 order sustaining the demurrer. (§ 581, subd. (f)(1).) Relying on Cromwell v. Cummings (1998) 65 Cal. App.4th Supp. 10, 76 Cal.Rptr.2d 171 and Malovec v. Hamrell (1999) 70 Cal.App.4th 434, 82 Cal.Rptr.2d 712, it ruled that an order "sustaining a demurrer without leave to amend is a dispositive judicial ruling, ... [a]ll that's left is a, quote, `dismissal,' which any party under [section] 581 can request.... [¶] Once a court makes a dispositive judicial ruling, then the Court loses jurisdiction, [and], as a matter of law, a [section] 128.7 motion is moot. It can't be initiated ... and it can't be heard or ruled on pursuant to a noticed motion by a party."[2]
Banks appealed from the order sustaining the demurrer but abandoned the appeal. Van Trees cross-appealed from the order vacating the award for sanctions.

30-Day Safe Harbor Provision
Section 128.7 requires that an attorney in a civil action "sign all pleadings, petitions, notice of motions and other similar papers. (§ 128.7, subd. (a).) The signature indicates that the attorney ... certifies that: the paper is not being presented for an improper purpose; the legal contentions are warranted by law or nonfrivolous argument for extension, modification or reversal of existing law; the allegations and factual contentions have evidentiary support or are likely to have such support after a reasonable opportunity to further investigate; and the denials of factual contentions are warranted by the evidence. (§ 128.7, subd. (b).) If the court determines, after notice or a reasonable opportunity to respond, that the attorney ... improperly certified the document, it may impose an appropriate sanction. (§ 128.7, subd. (c).)" (Barnes v. Department of Corrections (1999) 74 Cal.App.4th 126, 130, 87 Cal.Rptr.2d 594.)
Where the complaint is frivolous, sanctions may be imposed against the plaintiffs attorney, but not the plaintiff. (§ 128.7, subd. (d)(1).) Section 128.7, subdivision (c)(1) requires that the party seeking sanctions "follow a two-step procedure. First, the party must serve a notice of motion for sanctions on the offending party at least 30 days before filing the motion with the court, which specifically describes the sanctionable conduct. (Ibid.) Service of the motion on the offending party begins a 30 day safe harbor period during which the sanctions motion may not be filed with the court. (Ibid.) If the pleading is withdrawn [or dismissed], the motion for sanctions may not be filed with the court. [Citation.] If the pleading is not withdrawn, the motion for sanctions may then be filed. (Ibid.)" (Levy v. Blum *806 (2001) 92 Cal.App.4th 625, 637, 112 Cal. Rptr.2d 144.)
The purpose of the 30-day safe harbor provision is to permit the "offending party to avoid sanctions by withdrawing the improper pleading during the safe harbor period. [Citation.] This permits a party to withdraw a questionable pleading without penalty, thus saving the court and the parties time and money litigating the pleading as well as the sanctions request." (Malovec v. Hamrell, supra, 70 Cal. App.4th at p. 441, 82 Cal.Rptr.2d 712; see Hart v. Avetoom (2002) 95 Cal.App.4th 410, 414-415, 115 Cal.Rptr.2d 511 [sanctions improper where sanctions motion filed after case dismissed and motion filed was different from motion served; "new and improved" sanctions motion violated 30 day safe harbor requirement].)
Here the trial court erred in ruling that it "lost jurisdiction" to award sanctions. The cases cited by the trial court are inapposite. In each case, the motion for sanctions was filed after entry of judgment and in violation of the 30-day safe harbor provision. (Cromwell v. Cummings, supra, 65 Cal.App.4th at p. Supp. 13, 76 Cal.Rptr.2d 171 [motion served after dismissal, 21 days before sanctions hearing]; Malovec v. Hamrell, supra, 70 Cal. App.4th at pp. 441-444, 82 Cal.Rptr.2d 712 [dismissal during 30 day safe harbor period barred award for sanctions].)
Van Trees timely served the motion for sanctions and waited until the safe harbor period passed. Counsel for Banks was on notice that the action was frivolous and should be dismissed. Instead, he requested an extension, filed a first amended complaint, opposed the demurrer, and moved for relief from default and new trial after the trial court sustained the demurrer without leave to amend. The trial court found that the action was "completely unjustified and a shining example of a violation of 128.7."
After Banks moved for new trial, the trial court misconstrued dicta, Cromwell v. Cummings, supra, 65 Cal.App.4th Supp. 10, 76 Cal.Rptr.2d 171, which states that "a request for sanctions under section 128.7 brought subsequent to judicial disposition of the improper pleading must be treated as untimely." (Id., at p. Supp. 13, fn. 2, 76 Cal.Rptr.2d 171.)
Similar dicta appears in Malovec v. Hamrell, supra, 70 Cal.App.4th at p. 441, 82 Cal.Rptr.2d 712: "A sanctions motion may not be brought after the conclusion of the case or a dispositive ruling on the improper pleading. (Ibid.) Thus, a sanctions motion challenging a complaint may not be brought following the sustaining of a demurrer without leave to amend. [Citation.] Nor may a sanctions motion challenging an amendment to a complaint to name Doe defendants be brought following the dismissal with prejudice of the fictitiously named defendants. [Citation.] Neither may a motion for sanctions for filing a bad faith or frivolous complaint be brought following the granting of a defendant's motion for summary judgment."
The correct principle to be distilled from Cromwell and Malovec is that an order sustaining a demurrer without leave to amend does not bar a motion for section 128.7 sanctions unless the order is reduced to a judgment before the sanctions motion is served and filed. (Compare Laborde v. Aronson (2001) 92 Cal.App.4th 459, 465, 112 Cal.Rptr.2d 119 [motion for summary judgment and motion for § 128.7 sanctions granted at same hearing], with Hart v. Hart (2002) 95 Cal.App.4th 410, 415, 115 Cal.Rptr.2d 511 [sanctions motion filed after dismissal untimely].)[3] "[A] section *807 128.7 sanctions motion served and filed by a defendant after judgment has been entered cannot properly be granted if the conduct alleged to be sanctionable is the improper filing and/or advocating of the plaintiffs complaint." (Barnes v. Department of Corrections, supra, 74 Cal.App.4th at p. 128, 87 Cal.Rptr.2d 594; emphasis added.)
Section 128.7, subdivision (c)(1) requires that the motion for sanctions "be made separately from other motions or requests ...." The service and notice requirements of section 128.7 can be a trap for the unwary under the fast track rules if the sanctions motion is filed in tandem with a demurrer or motion for summary judgment. One practice guide suggests that "[I]f you're seeking § 128.7 sanctions, serve your sanctions motion before demurring, moving for summary judgment, etc. After the 30-day hold, if the opposing party has not withdrawn or cured the offense voluntarily, you can the file your sanctions motion concurrently with your demurrer or summary judgment motion." (Cal. Practice Guide, Civil Procedure Before Trial (Rutter 2001) ¶ 9:1206.30, p. 9(111) 38.) Van Trees recognized this potential problem and served the motion for sanctions and demurrer in proper sequence. The trial court erred in ruling that the sustaining of the demurrer eviscerated Van Trees' right to seek sanctions.
The purpose of section 128.7 is to deter frivolous actions and give the offending party the opportunity to withdraw or otherwise correct the pleading. (Barnes v. Department of Corrections, supra, 74 Cal. App.4th at p. 134, 87 Cal.Rptr.2d 594.) This purpose may be defeated if the trial court's reasoning is correct. Because sanctions were only imposed against Banks' attorney, our holding strikes a proper balance between section 128.7's competing interests"the need to restrict improper litigation `tactics' and the desire to avoid chilling vigorous advocacy. [Citation.]" (Pacific Trends Lamp & Lighting Products, Inc. v. J. White, Inc. (1998) 65 Cal.App.4th 1131, 1136, 76 Cal.Rptr.2d 918.)
The judgment is reversed. The trial court is directed to reinstate the October 11, 2000 award for sanctions against counsel for Banks. Counsel for Banks shall pay costs on appeal.
We concur: GILBERT, P.J., and COFFEE, J.
NOTES
[1]  All statutory references are to the Code of Civil Procedure.
[2]  Banks' motion for new trial was ordered off calendar as moot. Van Trees' motion to fix monetary sanctions was mooted by the order vacating the October 11, 2000 sanctions award.
[3]  In Liberty Mutual Fire Ins. Co. v. McKenzie (2001) 88 Cal.App.4th 681, 105 Cal.Rptr.2d 910, the trial court awarded section 128.7 sanctions after the offending party secretly dismissed its cross-complaint during the 30 day safe harbor period. Banks employed a similar tactic and filed a dismissal without prejudice three days before the hearing on the sanctions motion. The trial court vacated the dismissal.
