Sturm won a split decision after a superb fight with two judges favouring Sturm by 116-112 and the other seeing it 115-113 for Macklin.
Sturm's sharper work in the second half of the contest swung the fight his way.
Macklin made a blazing start which gave him genuine hope of an upset before fading late on.
Sturm is unbeaten in five years and was making his 10th defence in his second reign as WBA middleweight champion, on his own show in his home city.
But if the odds were stacked against Macklin, who had himself not tasted defeat since 2006, he shrugged them off in an explosive start in which he slung hooks to Sturm's body and made the champion cover up.
Far from blowing himself out, Macklin appeared to grow stronger as the early rounds progressed with Sturm relying on single, accurate shots to repel his opponent's continuous advances.
But Sturm finally got to grips with fight as it moved deeper into the second half, gaining control behind a stiff jab which had scarcely been in evidence in the opening stages.
Sturm enjoyed a big 10th round when a crashing uppercut followed by a right cross had Macklin temporarily in trouble, but the Irishman continued to fight back in pursuit of his dream.
Sturm caught the eye again in the last, finishing the contest with a furious assault which left Macklin almost out on his feet. Although both men claimed victory at the end, the verdict went with Sturm.
Macklin insisted: "I should be champion. I believe I was the better fighter, but it is not Felix's fault, he wasn't a judge."
But Sturm said: "It wasn't a wrong decision, but it was close.
"It was not my most outstanding performance, but I have had a few clear shots and Matt worked hard. In my view, the decision was absolutely correct.
"We will definitely have a second fight, we have already agreed it."
Meanwhile, Kell Brook kept his world title ambitions on course with a comfortable points victory over Lovemore N'Dou in his home city of Sheffield.
Brook now has 24 wins and no defeats, although he was unable to extend a run of eight wins inside the distance against the wily veteran.
Germany's Felix Sturm edged a tough contest against Birmingham-based Irishman Matthew Macklin in their WBA middleweight title fight in Cologne.