A magnetic lock (1) for a door or window, comprising a lock body (2) installable inside an opening of a leaf and a rotary latch (3) hinged to the lock body (2). The rotary latch (3) is reversibly movable between a retracted position, in which it is housed inside the lock body (2), and at least one extracted position, in which it is at least partially projecting from the lock body (2) in order to be engaged inside a strike plate of the door or window, thereby defining a closed condition of the door or window. Furthermore, the magnetic lock (1) comprises locking means (4) selectively activatable on the rotary latch (3) to keep it in said at least one extracted position, thereby defining a locked condition of the rotary latch (3). In particular, the locking means (4) defines with the rotary latch (3) a play (G) such that the rotary latch (3) defines the closed condition of the door or window, the extracted position being adjusted based on the positioning of a limit stop portion of the strike plate.