Rights of way have been established and agreed internationally to ensure that aircraft in proximity with each other in VMC know which aircraft has right of way over the other and what action must be taken to avoid collision.
Right-of-way rules are described in ICAO Annex 2: Rules of the Air, as follows:
3.2.1 Right-of-way. The aircraft that has the right-of-way shall maintain its heading and speed.
22.214.171.124 An aircraft that is obliged by the following rules to keep out of the way of another shall avoid passing over, under or in front of the other, unless it passes well clear and takes into account the effect of aircraft wake turbulence.
126.96.36.199 Approaching head-on. When two aircraft are approaching head-on or approximately so and there is danger of collision, each shall alter its heading to the right.
188.8.131.52 Converging. When two aircraft are converging at approximately the same level, the aircraft that has the other on its right shall give way, except as follows:
a) power-driven heavier-than-air aircraft shall give way to airships, gliders and balloons;
b) airships shall give way to gliders and balloons;
c) gliders shall give way to balloons;
d) power-driven aircraft shall give way to aircraft which are seen to be towing other aircraft or objects.
184.108.40.206 Overtaking. An overtaking aircraft is an aircraft that approaches another from the rear on a line forming an angle of less than 70 degrees with the plane of symmetry of the latter, i.e. is in such a position with reference to the other aircraft that at night it should be unable to see either of the aircraft’s left (port) or right (starboard) navigation lights. An aircraft that is being overtaken has the right-of-way and the overtaking aircraft, whether climbing, descending or in horizontal flight, shall keep out of the way of the other aircraft by altering its heading to the right, and no subsequent change in the relative positions of the two aircraft shall absolve the overtaking aircraft from this obligation until it is entirely past and clear.
Separate rules apply to aircraft Landing (220.127.116.11), Taking off (18.104.22.168), and Taxiing (22.214.171.124).
In the EU, the right of way is covered by Commission Regulation (EU) No 923/2012 laying down the common rules of the air and operational provisions regarding services and procedures in air navigation (SERA). The specific texts can be found in Annex, Section 3, Chapter 2, SERA.3210.