The Gardiner-Masur compactification of Teichmüller space is homeomorphic to the horofunction compactification of the Teichmüller metric. Let ξ and η be a pair of boundary points in the Gardiner-Masur compactification that fill up the surface. We show that there is a unique Teichmüller geodesic which is optimal for the horofunctions corresponding to ξ and η. In particular, when ξ and η are Busemann points that fill up the surface, the geodesic converges to ξ in forward direction and to η in backward direction. As an application, we show that if Gn is a sequence of Teichmüller geodesics passing through Xn and Yn such that Xn→ξ and Yn→η, then Gn converges to a unique Teichmüller geodesic.