Methods and devices for selectively removing from a subject a target cell, pathogen, or virus expressing a binding partner on its surface are presented. In one embodiment, the device contains an excorporeal circuit, which includes, at least, a magnetic filter comprising a magnet and a removable, magnetizable substrate capable of capturing magnetic nanomaterials; and a pump in fluid communication with the magnetic filter, wherein the pump moves fluid through the excorporeal circuit. The magnet is capable of generating a magnetic field sufficient to capture magnetic nanomaterials in the magnetic field. In a preferred embodiment, the target cells are cancer cells and/or cells infected with pathogenic agents. The devices may be designed for extracorporeal or in vivo uses. Functionalized superparamagnetic nanoparticles are either mixed ex vivo with a biological fluid from the patient or injected into the patient. Then the biological fluid, which includes the nanoparticles is transported to the magnetic filter to remove any nanoparticles that are complexed to the target cells, pathogens, or virus, and any free nanoparticles. Optionally, the functionalized nanoparticles contain and deliver a therapeutic agent. In one embodiment, the therapeutic agent is released when the nanoparticle binds to the target cells, pathogens, or virus.