How close can planes fly to each other over the ocean?
It was only very slightly higher than our plane by mere meters.


You think you saw a plane at the exact same vertical level as yours, when in fact it was at least 300 metres (1000 feet) above or below your level. It can be very hard to judge differences in level for the untrained eye, especially over the ocean and at night when there is nothing to reference for scale. Your confusion is understandable, but there was absolutely no safety risk here.

The minimum vertical separation between two aircraft is 1000 feet, and the plane you saw was - with 100% certainty - at least 1000 feet above or below you. This is ensured by air traffic control and a ton of complex regulations and rules governing air traffic.

When over the ocean, where no radar coverage exists, if two planes are flying at the same level, they will either be at least 10 minutes flying time apart (if following the same route), or 25 nautical miles (about 50 kilometres) if flying on parallel routes. Over land where there is radar, two aircraft at the same level will generally be at least 5 nautical miles apart (10 kilometres). But when 1000 feet or more vertical separation exist, aircraft can cross each others paths without any risk. It is perfectly normal for aircraft to fly this close, but passengers seem to take notice more often over the ocean, probably because there is nothing else to look at.

There was no risk of collision during your flight. If, for some inexplicable reason, the standard separation described above was violated, pilots and air traffic controllers would have responded immediately to establish separation again, long before any sort of collision risk would occur. There is very reliable technology in place to warn pilots and air traffic controllers if aircraft are getting too close, and they are trained to react to such warnings without delay.

For more information on separation, please see my answer on "How are aircraft separated at high altitudes?"