Oosthuizen, who won the Claret Jug at St Andrews in 2010, was four over through eight holes playing with world number one Tiger Woods and 2010 US Open champion Graeme McDowell.
He appeared to be limping and after teeing off at the ninth decided to pull out.
The 30-year-old South African quit after the first round at last month's US Open because of a neck injury for which he has been having treatment since it forced him out of the Byron Nelson Championship in May.
Oosthuizen's management company ISM confirmed the period of rest the player had been advised to take is likely to mean he misses next month's US PGA Championship.
"I am bitterly disappointed to have to pull out of The Open and it looks likely now I am going to have to take some time off and give my neck the rest I've been told it needs," he said.
"I thought I would be okay as I warmed up pretty well on the range but then as the round progressed the pain in my neck translated into my hips and I found it increasingly uncomfortable to walk.
"The Open means so much to me and having to withdraw in this manner is extremely disappointing on top of also having to pull out of Merion."
By then Swede Hanson had already gone, lasting five holes.
The 35-year-old, the only member of last year's victorious Ryder Cup team to miss May's BMW Championship at Wentworth, had been struggling with a back injury.
He admitted on the eve of the tournament his participation was 50-50 but he decided to start, which was a double blow to Dutchman Luiten who had been waiting all day to discover whether he would get a lucky break to play in his third successive Open.
Sweden's Alexander Noren became the third player to withdraw, pulling out with a wrist injury after shooting a 12-over 83.