Johnny Russell fired United ahead after just 15 seconds of the fifth-round tie and Jon Daly made it 2-0 on 36 minutes.
Russell's 16th goal of the season 11 minutes from time killed Rangers off and their miserable afternoon was completed by the late dismissals of Kal Naismith and Ian Black.
Naismith went for a late lunge at Willo Flood four minutes from time and Black followed him down the tunnel after a badly timed tackle on John Rankin.
McNamara told Sky Sports 1: "The result gives everyone a lift.
"I know we have got potential. The front three were very sharp today.
"We've got some good players here and hopefully we can kick on now. It's the first step today.
"Rangers were possibly the better team in the second half but we defended well. It was eight games without a clean sheet before today so that was a plus for us."
Russell told Sky Sports 1: "It's massive for us. To get a good result like that against Rangers at home is great for the boys and for the fans as well.
"This is what we play for, days like this. The boys will get a massive lift from that."
Daly, asked about McNamara's immediate impact on the home side, said: "He's not had a lot of time to deal with the boys. He set us out in a different shape and it worked pretty well."