Intelligent reflecting surface (IRS) is envisioned for beyond 5G systems due to its capacity to boost the spectral and energy efficiencies of wireless communications. The decoupled estimation of the involved communication channels is a non-trivial task in IRS-assisted wireless communications, especially for passive IRS structures. In this context, the joint design of the pilot sequences and the IRS phase shifts for channel estimation (CE) is challenging. In this paper, we provide an analytical solution to jointly design an optimal pilot and IRS phase shift matrices, leading to an improved CE performance. The solution consists of a factorization procedure that exploits the intrinsic Khatri-Rao structure of the combined pilot and phase shift matrices. This design is also used to obtain decoupled estimates of the individual channel matrices. Our results also show the noise rejection gain obtained from the proposed CE scheme compared to the conventional LS method. The proposed joint design offers a more efficient computation in terms of FLOPs and results in a faster channel estimation process than that of the individual design approach.