He didn't want to lie; he just had no other choice.
Tips
history
Rooted in 《老子》 chapter 31: 兵者不祥之器,非君子之器,不得已而用之 — weapons are ill-omened tools; the superior person uses them only when there is no alternative. The idea of reluctant, necessity-forced action carried into the set phrase.
usage
Six characters (not four). Often a predicate: [action] 是不得已而为之的 [decision/choice]. Used to soften or excuse an unpleasant action. Pairs with 别无选择, 迫不得已.