Both masks are coverings for the nose and mouth. But the level and type of protection they offer differ in several areas.
Masks fit loosely to the face and so don't offer full protection from viruses and other airborne pathogens. According to the CDC, Non-surgical masks may not provide protection from fluids or may not filter particles, needed to protect against pathogens, such as viruses. They are not for surgical use and are therefore not considered personal protective equipment (PPE).
On the other hand, surgical masks are fluid-resistant. They are disposable, loose-fitting, and create a physical barrier between the wearer's mouth and nose and his or her immediate environment. Although They are for use in surgical settings and provide the aforementioned protection form fluids, they do not give full protection from viruses and other inhaled airborne pathogens,.
Respirators are personal protective equipment that provides more security from viruses and airborne pathogens. When properly used, they ensure a snug fit and filter airborne particles that safeguard health care and essential workers, construction workers, and other wearers who need protections.
This CDC infographic compares surgical masks and N95 respirators.