The goal of the present study was to determine the best quarter milk flow for teat cup detachment depending on lactational stage and milking interval to optimize the milking process in automatic milking systems (AMS). Milking characteristics and post-milking teat condition were recorded in an AMS with all actions from teat cleaning to post-milking teat dipping occurring in the same teat cup and liner (GEA DairyRobot R9500). In 24 dairy cows, 12 in early (<80 DIM) and 12 in late lactation (>180 DIM), 294 milkings were recorded during 12 consecutive days. Teat cup detachment was set at a quarter milk flow of 50, 87.5 or 125 g/min. Voluntary milking intervals varied similarly in cows in early (6.1–14.8 h) and late lactation (6.3–15.7 h). Total milk yield, milk production per h and average milk flow were higher in early than in late lactation cows. Total milk yield per milking did not differ between detachment levels. The mean milking time was reduced by up to 1.5 min at the highest compared to the lowest detachment level mainly in early lactation cows (P < 0.05). However, no significant effect of the detachment level on milking time was observed at milking intervals >10 h. Average milk flow was higher at milking intervals >10 h than ≤10 h (P < 0.05). In the early lactation cows (only) the average milk flow increased with higher detachment levels (P < 0.05). Teat condition did not differ among detachment settings or milking intervals. In conclusion, teat cup detachment up to 125 g/min reduces milking time in both early and late lactation without a loss of milk yield or affecting the teat condition. Combined with a higher average milk flow through avoiding too short milking intervals, the total milking time and hence stall occupancy can be optimized by early teat cup detachment.