However, Brian Laws side equalised just three minutes later through Jermaine Johnson.
Rangers, though, snatched what could prove to be a precious three away points when Kaspars Gorkss headed home what proved to be the winning goal just eight minutes from time.
"It was a real test of grit and determination so it's a nice win for us," Magilton said after the 2-1 win.
"We knew we were going to be under the cosh.
"I thought Sheffield Wednesday really pressed and they deservedly got back on track. We were under an awful lot of pressure.
"We've been praised for playing expansive football this season so it was good to see us have to dig in and battle.
"We're still very much a work in progress."