不得已而为之

bù dé yǐ ér wéi zhī

to have no other choice

to be the last resort

不

bù

no; not so

得

dé

to obtain

已

yǐ

already

而

ér

and

为

wéi

variant of 為|为[wei2]

之

zhī

(possessive particle, literary equivalent of 的[de5])