In this paper, we study the three-dimensional (3D) flow of an electrically conducting fluid in a cubic cavity with the top wall moving and subjected to an external magnetic field. The governing flow and electromagnetic field equations are integrated by a second-order space and time accurate numerical scheme, implemented on a graphics processing unit (GPU) with high parallel efficiency. Solutions for several Reynolds and Stuart numbers have been obtained on sufficiently fine grids to achieve grid independent solutions. As expected, the magnetic field significantly influences the circulation in the cavity and modifies the shape and locations of the primary and secondary eddies. The observed flow patterns are illustrated graphically as well as through selected line plots and tabulated data. With increasing magnetic field strength, the center of the primary eddy is seen to shift to the top right corner. Further, situations where the flow is unsteady in the absence of the magnetic field have become steady after a certain value of the magnetic interaction parameter.