We propose a novel space-division-based network-coding scheme for multiple-input multiple-output (MIMO) two-way relay channels (TWRCs), in which two multiantenna users exchange information via a multiantenna relay. In the proposed scheme, the overall signal space at the relay is divided into two subspaces. In one subspace, the spatial streams of the two users have nearly orthogonal directions and are completely decoded at the relay. In the other subspace, the signal directions of the two users are nearly parallel, and linear functions of the spatial streams are computed at the relay, following the principle of physical-layer network coding. Based on the recovered messages and message-functions, the relay generates and forwards network-coded messages to the two users. We show that, at high signal-to-noise ratio, the proposed scheme achieves the asymptotic sum-rate capacity of the MIMO TWRC within [ 1/ 2]log(5/4) ≈ 0.161 bits per user-antenna, for any antenna configuration and any channel realization. We perform large-system analysis to derive the average sum-rate of the proposed scheme over Rayleigh-fading MIMO TWRCs. We show that the average asymptotic sum-rate gap to the capacity is at most 0.053 bits per relay-antenna. It is demonstrated that the proposed scheme significantly outperforms the existing schemes.