The invention relates to a method of milking a group of dairy animals (A, B) comprising a first subgroup (A) and a second subgroup (B) by means of an automatic milking system (2), and wherein the milking system has to be flushed after a dairy animal from the second subgroup has been milked. The invention is characterized by the fact that the flushing step is postponed after a dairy animal from the second subgroup has been milked until at least a minimum number greater than or equal to two dairy animals from the second subgroup has been milked successively, or a subsequent dairy animal belonging to the first subgroup has been identified and the decision has been made that the dairy animal from the first subgroup presenting itself can be milked, or by postponing the milking of a dairy animal from the second subgroup until at least a minimum number greater than or equal to two dairy animals from the first subgroup has been milked successively.