Anya caused Macedonia problems all night and finished brilliantly on the hour mark as Scotland were rewarded for taking the game to their hosts.
Substitute Matt Gilks made a number of excellent saves before Ivan Kostovski levelled in the 84th minute, but Maloney curled into the top corner to lift Scotland off the bottom of their World Cup qualifying group.
Anya made his first international start. The Watford player, who made his debut in the 2-0 defeat by Belgium on Friday, came in with Barry Bannan and Steven Naismith, who was handed the lone striker role.
Leigh Griffiths, James Forrest and the suspended Robert Snodgrass dropped out.
Macedonia's playmaker and captain, Goran Pandev, shook off a shoulder problem to start for the hosts, who moved two points above Scotland with a 2-1 win over Wales on Friday.
The pitch had been much criticised after that game, with some suggestions it played a part in Gareth Bale's injury in training the previous night. And there were dozens of small patches of repaired turf in the half Scotland were shooting into in the opening period, although it looked bumpy all over.
The left-footed Bannan started on the right flank and he set up the first half-chance of the game with a sharp pass forward for Naismith, who fired wide from a difficult angle.
Anya caused some early problems for the hosts with some direct running round the outside on the left flank and he managed to get several balls into the box in the opening 15 minutes without any falling for a team-mate.
Pandev hooked an effort towards goal after a long throw but it could not trouble David Marshall and Scotland continued to have the territorial advantage.
The home fans were growing audibly frustrated by their team's inability to make tracks into Scotland's final third and their mood nearly deteriorated in the 26th minute following more positive wing play from Anya.
This time his cross fell for a Scotland player as Naismith got in front of his marker but the Everton player headed over from 10 yards.
Anya threatened again moments later but his cutback just evaded Naismith.
Scotland kept on the pressure and Alan Hutton's low cross was diverted just past the post by a Macedonian defender before Grant Hanley headed wide from Bannan's deep corner.
Scotland had an even better chance in the 32nd minute when they won the ball in the centre circle and Naismith lifted it over the Macedonian defence to feed Scott Brown's forward run.
The Celtic captain was clean through but his left-footed effort hit the diving home goalkeeper Tome Pachovski and held up for a home defender to clear.
Whittaker soon overlapped Ikechi but Pachovski smothered his low cross.
Macedonia brought on Darko Tasevski for David Babunski in the 42nd minute and the Scots came close again when Whittaker burst forward and fed Anya, whose first-time curling effort from 25 yards was pushed over by Pachovski.
Hanley's volley was blocked in the goalmouth from the resulting corner before the visitors had their first scare of the night when Aleksander Trajkovski broke down the left with Scotland short of bodies in defence.
The left winger found Adis Jakovikj with a reverse pass but he shot into the side netting and the home fans greeted the half-time whistle with loud jeers.
Scotland were forced into a half-time change with Matt Gilks making his competitive debut after Marshall went off with a hip injury.
The second half started in farcical fashion with Pachovski not even on the park when French referee Fredy Fautrel blew his whistle. The game kicked off at the second attempt as the goalkeeper sprinted on to a mix of derision and laughter.
Macedonia enjoyed their first spell of sustained pressure but Gilks was untroubled and Anya curled wide from 20 yards after a Scotland counter-attack.
Scotland took the lead on the hour mark after a promising Macedonian break ended with Mirko Ivanovski shooting well wide. Scotland got the ball forward and Bannan fizzed a pass to Anya in a couple of yards of space on the edge of the box. The Glasgow-born wide man took a good touch, ran into the box and fired a left-footed effort just inside the far post before running towards the Scotland fans in delight.
Scotland sat back in the immediate aftermath of the goal and Charlie Mulgrew was booked for a poor challenge in the centre circle.
The hosts initially struggled to break Scotland down but Gilks made three excellent saves within five minutes.
Tasevski set up the first chance in the 70th minute with a probing pass from the centre circle which found Ivan Trickovski. The winger tried to shoot across Gilks but the Blackpool goalkeeper got down well to save before grasping the loose ball.
Scotland were then caught on the counter-attack and Macedonia worked the ball to Mirko Ivanoivski on the right and Gilks pushed away his swerving strike.
The Blackpool goalkeeper then pushed over a first-time effort from Trickovski, who soon volleyed into the side net.
Shaun Maloney fired just wide at the other end with Bannan yelling for a lay-off. The Crystal Palace midfielder was soon replaced by James McArthur.
Whittaker and Anya were booked for time-wasting before Ivanovski fired over after getting a yard of space on the edge of the box, and the former was soon taken off for Lee Wallace with 10 minutes remaining.
Scotland looked to have weathered the storm but the equaliser came in the 84th minute. The Scots had plenty of men back when Maloney lost the ball on the left, but substitute Kostovski got ahead of the visiting defence to meet Pandev's dinked cross from the left and he stabbed it past Marshall as the keeper came out.
However, the Scots got the win they deserved after McArthur was brought down 22 yards out after skipping in between two defenders. Maloney took the free-kick and curled it superbly into the top corner past the diving goalkeeper.
There was still time for Kostiovski to head wide from a decent chance before Wallace came very close with the last kick of the ball.