Abstract A virtual fencing (VF) system is based on a smartphone application that defines an invisible grazing boundary based on global positioning. Animals are tracked via GPS collars. When reaching the virtual boundary, the collar emits an ascending audio tone, followed by a mild electric pulse (0.2 Joule) when crossing it. The technology is particularly promising in rough and extensive mountainous areas where physical fencing is difficult and more time-consuming. Environmental conditions may also affect the functionality of the VF system, with potential impacts on animal behavior. Therefore, the present study tested a VF system on 30 female heifers in a rotational grazing system on Swiss mountain pastures (approximately 1,300 to 1,500 m above sea level). Each heifer was equipped with a VF collar (Nofence AS, Batnfjordsør, Norway) for individual recording of audio tones and electric pulses. After two wk of VF training in the lowlands (approximately 700 m above sea level), during which the heifers learned to interpret the VF signals correctly, they were transported to the mountain pasture. For mountain grazing, the herd was divided into three groups of 10 heifers each, balanced for age (mean ± SD: 11.9 ± 1.6 mo) and breed (Holstein-Friesian, Montbeliarde, crossbreeds). The outer perimeter of the mountain pasture was surrounded by an electric fence. Its inner area was divided into 3 electrically fenced and 6 virtually fenced paddocks. For 83 d, all groups grazed simultaneously in separate paddocks and rotated sequentially through the 9 paddocks. Video cameras were placed along the virtual fences to record animal responses after receiving audio tones or electric pulses. Moreover, grass height was measured using a rising plate meter to estimate forage availability in the currently grazed paddocks. Throughout mountain grazing, each heifer received an average of 4.9 ± 6.9 audio tones and 0.3 ± 0.7 electric pulses per day. Generalized mixed-effects models revealed that the number of audio tones and electric pulses did not change over grazing periods or among days after paddock change. Behavioral responses of the animals were less pronounced once the heifers had learned the VF system. In addition, grazing interruptions after receiving an audio tone or electric pulse were shorter during mountain grazing compared with the training period (P < 0.001). Furthermore, lower grass heights (P < 0.05) as well as the occurrence of (common but) unpredictable events (P < 0.001), such as the presence of wildlife (e.g., lynx, deer) or neighboring cattle, increased the number of audio tones and electric pulses during mountain grazing. The VF system was still effective in keeping the heifers within their assigned paddocks under mountainous conditions. However, a well-considered handling when changing paddocks as well as a careful placement of the virtual fence is essential to avoid negative effects on the animals.