An optical module comprising: a mirror unit having a movable mirror portion including a coil (11, 12), the mirror unit comprising a support portion, a coupling portion (5, 6) coupling the movable mirror portion to the support portion, and a base to which the support portion is attached; a magnet portion having an upper surface, a bottom surface, and a side surface extending from the upper surface to the bottom surface, and configured to generate a magnetic field acting on the movable mirror portion; wherein the magnet portion has a Halbach structure including a first magnet including a first area on the bottom surface and applied with a force in a first direction from the upper surface to the bottom surface, and a pair of second magnets (52, 53), disposed with the first magnet interposed therebetween, including a second area (52a, 53a) on the upper surface and applied with a force in a second direction from the bottom surface to the upper surface, characterized in further comprising a package accommodating the magnet portion, wherein the package has a bottom wall portion configured to support the first area, a side wall portion supporting the side surface, and a restriction portion configured to restrict movement of the second magnets (52, 53) in the second direction by covering only a portion of the second area (52a, 53a), and wherein the movable mirror portion is disposed in a space formed by the upper surface and the restriction portion. a mirror unit having a movable mirror portion including a coil (11, 12), the mirror unit comprising a support portion, a coupling portion (5, 6) coupling the movable mirror portion to the support portion, and a base to which the support portion is attached; a magnet portion having an upper surface, a bottom surface, and a side surface extending from the upper surface to the bottom surface, and configured to generate a magnetic field acting on the movable mirror portion; wherein the magnet portion has a Halbach structure including a first magnet including a first area on the bottom surface and applied with a force in a first direction from the upper surface to the bottom surface, and a pair of second magnets (52, 53), disposed with the first magnet interposed therebetween, including a second area (52a, 53a) on the upper surface and applied with a force in a second direction from the bottom surface to the upper surface, characterized in further comprising a package accommodating the magnet portion, wherein the package has a bottom wall portion configured to support the first area, a side wall portion supporting the side surface, and a restriction portion configured to restrict movement of the second magnets (52, 53) in the second direction by covering only a portion of the second area (52a, 53a), and wherein the movable mirror portion is disposed in a space formed by the upper surface and the restriction portion. a package accommodating the magnet portion, wherein the package has a bottom wall portion configured to support the first area, a side wall portion supporting the side surface, and a restriction portion configured to restrict movement of the second magnets (52, 53) in the second direction by covering only a portion of the second area (52a, 53a), and wherein the movable mirror portion is disposed in a space formed by the upper surface and the restriction portion.