Virtual fencing (VF) offers the possibility of replacing physical fences with a virtual system. A proper use of VF aims to condition animals to an audio tone (AT, 82 dB for 5-20 s) to avoid a light electric pulse (EP, 0.2 J for 1 s). The present study investigated the learning behaviour of 10 lactating cows under VF and its effects on cow behaviour and welfare compared to 10 cows managed with electric fences (EF). Both treatments were split into groups of 5 (2× VF, 2× EF) balanced by age and lactation stage. Each group grazed half-day in a separate, EF paddock during a 3 d lead-in period (P0) with inactive VF, followed by 4 periods (P1-4) with active VF. All cows were equipped with a VF collar (Nofence AS, Batnfjordsøra, Norway) and an IceQube pedometer (Peacock Technology Ltd., Stirling, UK). We continuously monitored cow activity and daily milk yield, body weight, and feed intake. Further, we recorded milk cortisol and the frequency of agonistic interaction, vocalization and excretion at the start, middle, and end of P0-P4. During 59 d, the cows received a mean of 108±54 AT and 7±3 EP. At Day 1, the number of EP was highest (18) but decreased to 5 at Day 3 (-72%) and remained below that threshold for the rest of the trial. With each paddock change, cows were successively conditioned to the AT, which was reflected in a decreasing ratio of EP/AT from Week 1 (22%) to Week 4 (2%), 6 (1%), and 8 (0%). Milk yield, milk cortisol, feed intake, body weight, and activity were similar in VF and EF groups. Throughout the trial, we observed a mean of 11.2 vocalizations and 5.9 displacements more per cow in the VF groups compared to the EF groups (P<0.05). However, their frequency did not differ between P0-P4. Our results indicate that all cows learned to cope with the VF system without lasting behavioural changes or negative effects on animal welfare. The conditioning of the cows to the AT of the VF system succeeded at herd level after 3 repetitions on a new virtual fence.