Attachment is a necessary first step in bacterial commitment to surface-associated behaviors that include colonization, biofilm formation, and host-directed virulence. The Gram-negative opportunistic pathogen Pseudomonas aeruginosa can initially attach to surfaces via its single polar flagellum. Although many bacteria quickly detach, some become irreversibly attached and express surface-associated structures, such as Type IV pili, and behaviors, including twitching motility and biofilm initiation. P. aeruginosa that lack the GTPase FlhF assemble a randomly placed flagellum that is motile; however, we observed that these mutant bacteria show defects in biofilm formation comparable to those seen for non-motile, aflagellate bacteria. This phenotype was associated with altered behavior of ΔflhF bacteria immediately following surface-attachment. Forward and reverse genetic screens led to the discovery that FlhF interacts with FimV to control flagellar rotation at a surface, and implicated cAMP signaling in this pathway. Although cAMP controls many transcriptional programs in P. aeruginosa, known targets of this second messenger were not required to modulate flagellar rotation in surface-attached bacteria. Instead, alterations in switching behavior of the motor appeared to result from direct or indirect effects of cAMP on switch complex proteins and/or the stators associated with them., Author summary Attachment to a surface often triggers programs of gene expression that alter the behavior, virulence and fitness of bacteria. Initial contact is usually mediated by surface exposed adhesins, such as flagella or pili/fimbriae, and there is much interest in how these structures might sense and respond to surface attachment. The human bacterial pathogen Pseudomonas aeruginosa can initially contact surfaces via its polar flagellum, the structure that also powers bacterial swimming. We observed that wild-type bacteria quickly stopped rotating their flagellum after surface attachment, but that a mutant lacking the flagellar-associated protein FlhF did not. Using a combination of genetic approaches, we demonstrated that FlhF interacts with a component of the flagellar rotor (FliG) and with a polar scaffolding protein that positively regulates cAMP production (FimV) to stop flagellar rotation and thereby favor bacterial persistence at a surface. We provide evidence that the second messenger cAMP is the likely signal generated by flagellar-mediated surface attachment and show that cAMP is sufficient to alter the behavior of the flagellar motor.