Motor surging when idling

motor surging when the truck 2001 ford explorer sport trac v6 is idling. sometimes it stalls out and sometimes the truck will not start at all it will try to start but want but mostly the surging when in idle. what could the problem with this?

The most common cause of a surging idle is a vacuum leak.

If yours will also stall out & starts with difficulty then it is likely a fairly large leak. It may be big enough to find just by eyeballing it, but vacuum leaks hiss - so you can listen for them. Or you can feed some propane or butane from an unlit torch around intake, vacuum lines/connections, etc. There should be a vacuum schematic under the hood.