When I read this question, I had another question: Why can the dead men of Dunharrow kill the corsairs from the south if they are immaterial ghost?
Gimli (and Legolas) described what happened in Chapter 9 of ROTK (bolded text mine):
And there men of Lamedon contested the fords with fell folk of Umbar and Harad who had sailed up the river. But defenders and foes alike gave up the battle and fled when we came, crying out that the King of the Dead was upon them. ...
... and Gimli continued:
... There at Pelargir lay the main fleet of Umbar, fifty great ships and smaller vessels beyond count. Many of those that we pursued had reached the havens before us, and brought their fear with them; and some of the ships had put off, seeking to escape down the River or to reach the far shore; and many of the smaller craft were ablaze. But the Haradrim, being now driven to the brink, turned at bay, and they were fierce in despair; and they laughed when they looked on us, for they were a great army still.
'But Aragorn halted and cried with a great voice: "Now come! By the Black Stone I call you! " And suddenly the Shadow Host that had hung back at the last came up like a grey tide, sweeping all away before it. Faint cries I heard, and dim horns blowing, and a murmur as of countless far voices: it was like the echo of some forgotten battle in the Dark Years long ago. Pale swords were drawn; but I know not whether their blades would still bite, for the Dead needed no longer any weapon but fear. None would withstand them. 'To every ship they came that was drawn up, and then they passed over the water to those that were anchored; and all the mariners were filled with a madness of terror and leaped overboard, save the slaves chained to the oars.
As you can see, their weapon we fear and terror, nothing physical.
And of course, they then were released by Aragorn, well before Jackson-versioned appearance at Minas Tirith. As Gimli continues the story of Pelagrir battle:
Then he [Aragorn] let sound a great concourse of trumpets taken from the enemy; and the Shadow Host withdrew to the shore. There they stood silent, hardly to be seen, save for a red gleam in their eyes that caught the glare of the ships that were burning. And Aragorn spoke in a loud voice to the Dead Men, crying: ' "Hear now the words of the Heir of Isildur! Your oath is fulfilled. Go back and trouble not the valleys ever again! Depart and be at rest! " 'And thereupon the King of the Dead stood out before the host and broke his spear and cast it down. Then he bowed low and turned away; and swiftly the whole grey host drew off and vanished like a mist that is driven back by a sudden wind; and it seemed to me that I awoke from a dream.
As I recall from the books, they were not able to kill anyone, but their presence inspired fear in the corsairs, who abandoned their ship. They took no part in the battle of Minas Tirith in those books, in fact, the battle ended when the Corsair ships unfolded the Aragorn's banner.