A method of setting an origin in a linear motor having: a field yoke composed of a hollow cylindrical member and a plurality of permanent magnets arranged in the hollow cylindrical member, in a straight row, each with either pole facing and contacting the same pole of either adjacent permanent magnet; an armature having an armature coil arranged, facing the row of magnets and spaced by a magnetic gap from the row of magnets; characteristic-changing parts arranged at ends of the row of magnets or at the middle thereof and configured to abruptly change magnetic characteristic of the row of magnets; and a magnetic linear encoder using the row of magnets as magnetic scale unit, utilizing a distance between any two adjacent permanent magnets as scale pitch of the magnetic scale unit, and having a plurality of first magnetism-detecting units and a second magnetism-detecting unit, which are arranged in a lengthwise direction of the armature, the first magnetism-detecting units being so arranged to have a phase difference of 90°, which corresponds to 1/4 wavelength of the scale pitch, in terms of electrical angle with respect to each other, and the second magnetism-detecting unit being so arranged to have a phase difference of 180°, which corresponds to 1/2 wavelength of the scale pitch, in terms of electrical angle with respect to the first magnetism-detecting units, wherein one component selected from the group consisting of the field yoke and the armature is provided at the stator, and the other component is provided as a movable member, the magnetic linear encoder has a scale head provided at the armature, and the field yoke and the armature move straight relative to each other, the method comprising: moving the movable member toward an origin, thereby searching (S102, 202, 302, 402) for a position where the magnetic characteristic of the row of permanent magnets has abruptly changed; setting (105, 203, 303, 403) an origin-setting reference position based on the position searched for; decelerating the movable member at a prescribed deceleration from the origin-setting reference position set, and stopping the movable member at a stop position where the scale head acquires a predetermined value; moving (S106, S204, S404) the movable member back from the stop position, thereby searching for a polarity-changing point where the magnetic characteristic detected by the magnetic linear encoder has changed in polarity; and stopping the movable member at the polarity-changing point, and setting the polarity-changing point as a reference position for an absolute position of the linear motor. moving the movable member toward an origin, thereby searching (S102, 202, 302, 402) for a position where the magnetic characteristic of the row of permanent magnets has abruptly changed; setting (105, 203, 303, 403) an origin-setting reference position based on the position searched for; decelerating the movable member at a prescribed deceleration from the origin-setting reference position set, and stopping the movable member at a stop position where the scale head acquires a predetermined value; moving (S106, S204, S404) the movable member back from the stop position, thereby searching for a polarity-changing point where the magnetic characteristic detected by the magnetic linear encoder has changed in polarity; and stopping the movable member at the polarity-changing point, and setting the polarity-changing point as a reference position for an absolute position of the linear motor.