In this paper we compute the leading order Casimir energy for the electromagnetic field (EM) in an open ended perfectly conducting rectangular waveguide in three spatial dimensions by a direct approach. For this purpose we first obtain the second quantized expression for the EM field with boundary conditions which would be appropriate for a waveguide. We then obtain the Casimir energy by two different procedures. Our main approach does not contain any analytic continuation techniques. The second approach involves the routine zeta function regularization along with some analytic continuation techniques. Our two approaches yield identical results. This energy has been calculated previously for the EM field in a rectangular waveguide using an indirect approach invoking analogies between EM fields and massless scalar fields, and using complicated analytic continuation techniques, and the results are identical to ours. We have also calculated the pressures on different sides and the total Casimir energy per unit length, and plotted these quantities as a function of the cross-sectional dimensions of the waveguide. We also present a physical discussion about the rather peculiar effect of the change in the sign of the pressures as a function of the shape of the cross-sectional area.