Semiquantum key distribution (SQKD) allows two parties to share a common string when one of them is quantum and the other has rather limited quantum capability. Almost all existing SQKD protocols have been proved to be robust in theory, namely that if an eavesdropper tries to gain information, he will inevitably induce some detectable errors. However, ideal devices do not exist in reality and their imperfection may result in side-channel attacks, which can be used by an adversary to get some information on the secret key string. In this paper, we design a measurement-device-independent SQKD protocol for the first time, which can remove the threat of all detector side-channel attacks and show that it is also robust. In addition, we discuss the possible use of the proposed protocol in real-world applications and in QKD networks. Copyright © 2018 World Scientific Publishing Company.