To close this issue out - I replaced the transmission position sensor and the problem is gone. The sensor was $28 at the dealer and took about 30 minutes to install. The Ford tool mentioned in the Haynes manual is not required - there are aligment marks on the sensor.
Thanks for your help guys - this would have been one of those nasty intermittent problems that might have taken repeated trips to a mechanic to fix.