According to the statistics of water transportation accidents, collision accidents are on the rise as the shipping industry has expanded by leaps and bounds, and the water transportation environment has become more complex, which can result in grave consequences, such as casualties, environmental destruction, and even massive financial losses. In view of this situation, high-precision and real-time ship trajectory prediction based on AIS data can serve as a crucial foundation for vessel traffic services and ship navigation to prevent collision accidents. Thus, this paper proposes a high-precision ship track prediction model based on a combination of a multi-head attention mechanism and bidirectional gate recurrent unit (MHA-BiGRU) to fully exploit the valuable information contained in massive AIS data and address the insufficiencies in existing trajectory prediction methods. The primary advantages of this model are that it allows for the retention of long-term ship track sequence information, filters and modifies ship track historical data for enhanced time series prediction, and models the potential association between historical and future ship trajectory status information with the current state via the bidirectional gate recurrent unit. Significantly, the introduction of a multi-head attention mechanism calculates the correlation between the characteristics of AIS data, actively learns cross-time synchronization between the hidden layers of ship track sequences, and assigns different weights to the result based on the input criterion, thereby enhancing the accuracy of forecasts. The comparative experimental results also verify that MHA-BiGRU outperforms the other ship track prediction models, demonstrating that it possesses the characteristics of ease of implementation, high precision, and high reliability.