Both the jammer and the eavesdropper pose severe threat to wireless communications due to the broadcast nature of wireless channels. In this paper, an intelligent reflecting surface (IRS) assisted secure communication system is considered, where a base station (BS) wishes to reliably convey information to a user in the presence of both a jammer and an eavesdropper. We aim to maximize the system achievable rate by jointly designing the BS’s transmit beamforming and the IRS’s reflect beamforming, while meeting the maximum transmit power constraint, the minimum signal-to-interference-plus-noise ratio requirement of the legitimate user against jamming, and the minimum secrecy rate constraint of the legitimate user against eavesdropping. Due to the non-convexity and intractability of the original problem, we apply the Charnes-Cooper transformation to convert the original optimization problem into a tractable convex optimization problem, and then obtain the high-quality optimal solution by using the semidefinite relaxation (SDR) techniques and alternative optimization. Numerical simulations demonstrate the superiority of our proposed optimization algorithm compared with existing approaches, and also provide useful guidance into optimally deploying IRS in the secure communication system.