It depends on the situation.
'Rules of the road' at sea are guidelines.
Generally, the vessel being overtaken has priority. But don't take that to court if you are damaged by an oil tanker in your pleasure craft in a shipping lane. You will lose!
Chat with our AI personalities
The 'rules of the road' at sea are not set in stone as to what is right and wrong in all circumstances, they are guidelines. They are generalisations of sensible conduct. Priorities are assigned to guide people.
In general, overtaking vessels give way to vessels being overtaken.
However no one, at sea, would expect the master of an very large passenger or cargo vessel to give way to a small sailing boat.
The 'rules' assume people in charge of vessels on the water have some common sense.