Ryan Naderi flicked home the opener for the Gers inside nine minutes of the Ibrox clash after Djeidi Gassama’s shot was parried by the keeper.
Then Dragojevic opened his Rangers account soon after with a truly stunning strike.
The Serbian midfielder controlled the ball on his chest fully 25-yards from goal and let go a superb shot which flew into the top corner, giving Saints keeper Jacob Chapman no chance.
Chris Mochrie netted for the visitors before Gassama finished off a superb counter-attack on 53 minutes, with debutant James Penrice adding a fourth a minute later.
Ivor Pandur then saved a Killian Phillips penalty before Ross McCausland got in on the act as the Gers set up a quarter-final clash with Old Firm rivals Celtic.
Dragojevic was delighted to open his account for the club and said he will continue to strive to improve every day.
Speaking to RangersTV, Dragojevic said: “I am really happy with the win; I scored and managed to help the team.
“When you do everything to be the best version of yourself every day, I am happy to help us win.
“My role, when we have corners or free-kicks, I have to be on the side and wait for the ball and shoot when I can. I did my job, and I saw the opportunity, and it went in, and it was amazing.
“I haven’t scored from this distance before, but it was more important that we won the game. We have had a tough period, so it is more important than the goal.
“It was a big relief to get the first win of the season. In other games, we never got what we deserved.
“I think we deserved more; the results were bad, and we know that, but things are going better now, and we needed this win, and we will strive to be better day by day.”
Dragojevic says the cup victory is the perfect preparation for Thursday’s Conference League play-off with Czechia side Jablonec at Ibrox.
He added: “Was it important to build confidence ahead of Thursday? Absolutely.
“We are doing everything for this badge, and we want to be the best version of ourselves, and we will continue to look to get better day by day.”
MYGERS: From priority access and behind-the-scenes opportunities to special events and unique moments, MyGers brings you closer to the action on and off the pitch
RANGERS MUSEUM AND STADIUM TOURS: Experience the magic of Ibrox Stadium, with your very own ‘access all areas’ pass