The basis is that many non-Christians and even people who call themselves Christian but do not believe in Christ’s divinity describe Jesus as a great teacher. Lewis’s point is that He cannot just be a great teacher, because he taught that he is divine, the Son of God. So one must accept liar or lunatic along with being a great teacher, which would be a contradiction.
To apply the same test to Mohammed, one would have to agree to start with the premise he was a great teacher. Of course, many of us would say no, so the test really doesn’t apply to us. Just so, if someone says Jesus was not a great teacher, then Lewis’s trilemma would be meaningless to him also.
The logic only works by starting with the premise that he was a great teacher. In my experience, most people will abandon that premise when presented with the trilemma. Once that premise is abandoned, there is no longer a contradiction.