He resisted perhaps the greater part of those 30 years, when
Sauron only sporadically had dealings with him. But when Sauron focused (almost) his full attention on him, he was able to break
Denethor with despair.
Denethor has been using the
Palantir ever since he became Steward, and he has still managed to wring vital information out of it and discern falsehood from fact for all those years - and do that
in despite of Sauron. The fact that it took so long for Denethor to even waver is a testament to the man's strength and integrity.
There's a very specific moment in RotK when Denethor actually breaks, and it not entirely down to Sauron but to a combination of factors.
Denethor is already grieving the loss of
Boromir.
Faramir is brought to him, wounded and dying (or so he thinks). At that moment he is a father, plain and simple, struggling to deal with the death of both of his sons. It's a unique moment of vulnerability for him.
Then after Faramir is brought back to MT, he uses the Palantir for the last time. This time he doesn't only see the
armies of
Mordor: he also sees
Frodo captured and, by that, he thinks that Sauron has regained
the Ring. Seeing that - in his vulnerability - is what drives him to despair, not just the siege of MT.
Faramir is brought back to
Minas Tirith gravely injured on the same date (March 13) that Frodo is captured by the
orcs of
Cirith Ungol:
"[Denethor] himself went up alone into the secret room under the summit of the Tower; and many who looked up thither at that time saw a pale light that gleamed and flickered from the narrow windows for a while, and then flashed and went out. And when Denethor descended again he went to Faramir and sat beside him without speaking, but the face of the Lord was grey, more deathlike than his son’s."
Denethor has already referred to sending the Ring into Mordor as “a fool’s hope". He later says to
Pippin "
The fool’s hope has failed. The enemy has found it, and now his power waxes; he sees our very thoughts, and all we do is ruinous." He is very specifically referring to his belief that the war is hopeless due to Frodo’s capture and Sauron once again possessing the Ring.
He didn't break because he couldn't withstand Sauron. He broke because, in a moment of extreme grief and vulnerability, he knew something that
nobody else would know until their encounter with the
Mouth of Sauron. If the others had known the same, how many of them would have broken too?
Denethor is gravely misunderstood when he's percieved as 'weak'. And don't get me started on PJ's version of him as a crazy old man.