In this report we show that in Bacillus subtilis the flagellar switch, which controls direction of flagellar rotation based on levels of the chemotaxis primary response regulator, CheY-P, also causes hydrolysis of CheY-P to form CheY and Pi. This task is performed in Escherichia coli by CheZ, which interestingly enough is primarily located at the receptors, not at the switch. In particular we have identified the phosphatase as FliY, which resembles E. coli switch protein FliN only in its C-terminal part, while an additional N-terminal domain is homologous to another switch protein FliM and to CheC, a protein found in the archaea and many bacteria but not in E. coli. Previous E. coli studies have localized the CheY-P binding site of the switch to FliM residues 6-15. These residues are almost identical to the residues 6-15 in both B. subtilis FliM and FliY. We were able to show that both of these proteins are capable of binding CheY-P in vitro. Deletion of this binding region in B. subtilis mutant fliM caused the same phenotype as a cheY mutant (clockwise flagellar rotation), whereas deletion of it in fliY caused the opposite. We showed that FliY increases the rate of CheY-P hydrolysis in vitro. Consequently, we imagine that the duration of enhanced CheY-P levels caused by activation of the CheA kinase upon attractant binding to receptors, is brief due both to adaptational processes and to phosphatase activity of FliY.