Ultrafiltration works by applying a pressure gradient across a semipermeable membrane. This gradient forces water and small solutes out of the blood while retaining larger molecules like proteins and blood cells. The filtered fluid, known as ultrafiltrate, is then removed from the body, helping to maintain fluid balance.