Examine the petition. You'll know when your spouse is serious about divorce because you'll be served with a copy of the petition they've filed in court. The petition will show how the filing spouse wants to handle child custody, alimony and other issues. It will also come with a summons to a court hearing and a thorough listing of the marriage's income, assets and liabilities.
Answer the petition. The spouse receiving a petition for divorce is called the respondent. If they do not answer the petition or appear in court according to the summons, the respondent will likely loose any right to contest the divorce. The response to a divorce petition is usually a form document that allows the respondent to suggest how they'd like to handle issues in the divorce.
File a motion to show cause. If the petition is for a grounds divorce, the respondent can move the court to have the petitioner prove the grounds. A fault divorce can usually be granted for abuse (physical or mental), desertion, adultery, drug abuse, insanity, incarceration for felonious crimes and coercion or fraud in forming the marriage. The laws of the state will detail exactly what constitutes each of these grounds.
Refute evidence. At a show-cause hearing, the petitioner will present evidence, testimonial or otherwise, in attempt to prove the grounds for which they're seeking divorce. To fight the divorce, the respondent will have to show why the evidence presented does not rise to the level of grounds for divorce in that state. To do this will require a knowledge of the laws, a sense of the local precedents regarding the standards on grounds for divorce and some evidence countering the claims.
File for dismissal or negotiate the divorce. If the judge denies that grounds for divorce are present, the respondent can move for the petition to be dismissed. If the grounds are granted, there is essentially nothing left to do but negotiate and haggle over the details of how joint property will be divided. This in itself can be contentious and ultimately lead to the judge intervening to resolve an impasse.