A half-duplex amplify-and-forward two-way relay network consisting of two single-antenna sources and N relays with each having two antennas is considered in this paper. For such a system, a tight lower bound of pairwise error probability (PEP) of a maximum likelihood (ML) detector for any distributed linear dispersion code with a fixed average amplifier is derived, revealing that diversity gain function cannot decay faster than ln <sup xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">N</sup> SNR/SNR <sup xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">2N</sup> , where rm SNR is signal to noise ratio. Particularly for the network having two relays, a novel distributed quasi-orthogonal space-time block code (QO-STBC) is proposed with two significant advantages. One is that the equivalent channel matrices at both source nodes turn out to be the block-circulant matrices, with each block being a product of the two Alamouti channel matrices. The other is that the equivalent noises at the both source nodes are Gaussian and white. Therefore, like QO-STBC for a multi-antennas system, the proposed code for the relay system still maintains low-decoding complexity for the ML detector. Asymptotic PEP formula is attained to show that the proposed code enables the optimal diversity gain function, i.e., meeting the lower bound of diversity gain, and the optimal coding gain. In addition, a near optimal power allocation that maximizes the received SNR of the worse link is presented and examined through comprehensive computer simulations for various kinds of asymmetric relay channels.