The fouling of surfaces submerged in a liquid is a serious problem for many applications including lab-on-a-chip devices and marine sensors. Inspired by the versatility of cilia in manipulating fluids and particles, it is experimentally demonstrated that surfaces partially covered with magnetic artificial cilia (MAC) have the capacity to efficiently prevent attachment and adhesion of real biofouling agents - microalgae Scenedesmus sp. Actuation of the MAC resulted in over 99% removal of the algae for two different scenarios: (1) actuating the MAC immediately after injecting the algae into a microfluidic chip, demonstrating antifouling and (2) starting to actuate the MAC 1 week after injecting the algae into the chip and leaving them to grow in static conditions, showing self-cleaning. It is shown that the local and global flows generated by the actuated MAC are substantial, resulting in hydrodynamic shear forces acting on the algae, which are likely to be key to efficient antifouling and self-cleaning. These findings and insights will potentially lead to novel types of self-cleaning and antifouling strategies, which may have a relevant practical impact on different fields and applications including lab-on-a-chip devices and water quality analyzers.