The collision of two plane gravitational waves in Einstein's theory of relativity can be described mathematically by a Goursat problem for the hyperbolic Ernst equation in a triangular domain. We use the integrable structure of the Ernst equation to present the solution of this problem via the solution of a Riemann-Hilbert problem. The formulation of the Riemann-Hilbert problem involves only the prescribed boundary data, thus the solution is as effective as the solution of a pure initial value problem via the inverse scattering transform. Our results are valid also for boundary data whose derivatives are unbounded at the triangle's corners-this level of generality is crucial for the application to colliding gravitational waves. Remarkably, for data with a singular behavior of the form relevant for gravitational waves, it turns out that the singular integral operator underlying the Riemann-Hilbert formalism can be explicitly inverted at the boundary. In this way, we are able to show exactly how the behavior of the given data at the origin transfers into a singular behavior of the solution near the boundary.