Mathematical word problems are of interest to educators because of their importance in the curriculum, and to psychologists because of their value as a context for the study of transfer of problem solving. A classic issue in transfer of problem solving questions whether or not rule learning leads to inflexibility when the learned rule is no longer appropriate (eg, Luchins, 1942). The present set of studies investigated the differences in success rates on a transfer test and rule use between schoolchildren who were either given direct instruction with a rule different from the transfer test rule, or had an opportunity to discover that different (base) rule through contingency- based practice. The studies were conducted directly in the classrooms and with the classroom teachers providing the instruction in order to maximize their ecological validity and offer an immediate educational application. Overall, it was shown that although the instruction group students always acquired the base rule faster than the contingency group students, the latter usually performed better on the transfer test. Thus, contingency-based learning had a transfer advantage over the rule instruction. In Experiments 4 and 5 subjects' understanding of the problems' structure, rule use, and rule inference were assessed through questionnaires and, in Experiment 5, through the use of irrelevant information in the problems. Independently inferring solution-based rules during practice enhanced transfer test performance which required different rules. Also, subjects who inferred solution rules in the process of taking the transfer test were the subjects who did best on that test. Subjects who focused on the problems' context instead of the solution rules did not perform well. Therefore, problem-solving involving rules is not necessarily inflexible and may instead enhance the transfer performance as long as the base rules are not learned by rote through direct instruction. Contingency-based practice which allows the participants to infer rules can be recommended as a way of teaching for transfer of solving mathematical word problems