Understanding individual movements in heterogeneous environments is central to predicting how landscape changes affect animal populations. An important but poorly understood phenomenon is behavioural response to habitat boundaries and the way animals cross inhospitable matrix surrounding habitat patches. Here, we analyze movement decisions, flight behaviour, and activity of the endangered scarce large blue Phengaris (Maculinea) teleius, focusing on the differences among the patterns observed in patch interior, at patch boundaries and within matrix. The probability of crossing an external patch boundary, regardless of the land use in the adjacent area, was considerably lower than crossing a ‘control line’ within patch interior. Movement distances, flight durations and net squared displacement were largest in matrix, while similarly smaller at patch boundaries and in patch interior. The distribution of angles between successive movements was clearly clustered around 0° (indicating flight in a straight line) in matrix and at patch boundaries, but not in patch interior. There were no differences in time spent on foraging, resting and ovipositing between patch interior and boundaries, but the first two activities rarely, and oviposition never, happened in matrix. Our results suggest that although P. teleius adults do not avoid using the resources located in the boundaries of habitat patches, they often return to the interior of the patches when crossing their boundaries. However, having entered the matrix the butterflies perform relatively long and straight flights. The estimated probability of emigration and net squared distance implies that the dispersal between local populations is common in this species in the studied area.