Recently, a multiple-input multiple-output (MIMO) two-way X relay channel, where two groups of source nodes each having 2 nodes exchange independent messages via a common relay node, was studied in [1]. In this paper, we extend it to the generalized MIMO two-way X relay channel, where m ≥ 2 and n ≥ 2 source nodes are contained in two groups, respectively. Based on signal space alignment, a new beamforming scheme is proposed to maximize the minimum effective signal to interference plus noise ratios (SINRs) among all data streams. The beamforming vectors are designed by an iterative algorithm in which a closed-form solution is obtained in each step. Moreover, we show that the power allocation problem given the shape of the beamformers can be transformed as a linear programming problem. Simulation results show that the proposed beamforming scheme can achieve significantly better error performance than random beamforming schemes subject to signal space alignment only.