Some lawyers will tell you that there's no legal advantage in being the first spouse to file for divorce, although depending on the details of your particular case, it may give you a strategic edge. However, if your spouse beats you to the courthouse, all isn't lost. You can file a counterclaim of your own, which is essentially a complaint in response to your spouse's filing.
Filing a Counterclaim
If your spouse has already filed for divorce, you can't file a petition or complaint of your own. Instead, you must file a counterclaim, but this in essence acts as your own complaint. It bears the same case number as your spouse's filing, but it's a legal action in itself. If she decides she doesn't want the divorce and tries to dismiss the case, she can't – she can only dismiss her own pleadings, and your counterclaim will move ahead uncontested.
When There Are Two Petitions
If you try to file a divorce complaint -- rather than a counterclaim -- in the same county where your spouse has already done so, the court probably will not accept the second document. You might be able to file in a different county, but the court must usually dismiss your action when it learns of the other filing.
In some states, you and your spouse can file for divorce together, submitting a joint petition or complaint. This usually requires that your divorce be uncontested, and you may have to submit a signed marital settlement agreement to the court at the same time.