To recover attorney fees under the catalyst theory and CCP 1021.5, the plaintiff must show that (1) the lawsuit was a substantial factor in the plaintiff’s achieving the primary relief sought in its suit (whether by judicial decree, settlement or voluntary change), (2) the lawsuit had merit and achieved its catalytic effect by threat of victory, not by dint of nuisance and threat of expense, and (3) the plaintiff tried to settle before suing. To decide the first of these requirements, courts must determine the suit’s primary objective, compare results with those objectives, and decide whether the suit was a material factor in contributing to those results. Timing of suit and results can provide clues as to causation. If defendant changes after suit is filed, an inference of causation may arise shifting the burden of proof to the defendant. in this case, the trial court erred in denying fees on the ground that the Governor had directed the Water Resources Dept. to abandon the challenged project. The court should have determined whether the Governor’s decision was itself motivated by the lawsuit.