This paper investigates the system performance of a cognitive relay network with underlay spectrum sharing wherein the relay is exploited to assist both the primary and secondary transmitters in forwarding their signals to the respective destinations. To exploit spatial diversity, beamforming transmission is implemented at the transceivers of the primary and secondary networks. Particularly, exact expressions for the outage probability and symbol error rate (SER) of the primary transmission and tight bounded expressions for the outage probability and SER of the secondary transmission are derived. Furthermore, an asymptotic analysis for the primary network, which is utilized to investigate the diversity and coding gain of the network, is developed. Finally, numerical results are presented to show the benefits of the proposed system.