A master service agreement (MSA) is a governing document that oversees the relationship between two or more organizations.
This document sets up the basic framework for the relationship and provides a set of rules and guidelines that govern any interaction between those organizations. This can govern anything from project timelines to dispute resolution.
A statement of work is project-specific, not relationship-specific. The terms and requirements of the SOW are directly related to a project and its associated deliverables.
If the company relationship is governed by an MSA, the requirements of the SOW would need to adhere to the rules of the MSA and the entire document would be considered subordinate to the MSA.