They have the electromagnetic force in which two objects are attracted to one another in a specific field or range.
Magnetite. Lodestone is a type of magnetite.
Many rocks have magnetic properties (are capable of being magnetized, are magnetic, or are attracted by a magnet) derived from magnetic minerals in their composition like magnetite, hematite, and...
Some rocks can be magnetic because they have special minerals like nickel, steel, ect.
Many minerals have magnetic properties. Lodestone, for instance, is composed mostly of the mineral magnetite.