The decisive moment arrived as early as the 15th minute when Kenny Miller and Jon Daly combined to set up Law who kept his composure from the edge of the six-yard box.
Although Rangers deserved their win – with Alloa keeper Craig McDowall making a number of decent saves – they were never comfortable against a team who went into Saturday’s game unbeaten in three matches against the Glasgow giants this season.
And it was the hosts who created the first real chance of the match in the sixth minute when a Liam Buchanan lob landed narrowly wide of the right post.
Two minutes after Law had stroked Rangers in front, the battling Wasps were almost level through Kevin Cawley who fired wide from seven yards.
At the other end Miller struck a post and David Templeton had an effort saved by McDowall.
But Alloa, who knocked Rangers out of the Challenge Cup in December, had their chances too with Stephen Simmons heading over from inside the box after half an hour.
Simmons went even closer on the hour mark with another header while McDowall denied Templeton for a second time, on this occasion making a great save to block the striker’s well-struck volley.
McDowall was at it again on 77 saving brilliantly from Fraser Aird and three minutes from time he kept out a Kris Boyd header as Rangers were unable to extend their winning margin.
The win moves Rangers eight points clear of third-placed Hibs but they remain 13 adrift of Scottish Championship leaders Hearts who travel to Ibrox next weekend.
As for battling Alloa, who have performed well against the Gers this campaign, they remain deep in relegation trouble having collected just two points from their last eight league games.