I have heard that Harut and Marut did not actually taught magic, but they came with another knowledge that was to be used to counter magic. Is this true? If it is, then what knowledge did they bring?
Harut and Marut were two angels sent down by Allah (SWT). They did not teach magic until they warned those who wanted to learn , that they are just a test and if someone learns what they know , they will be kafir. Those who did not listen to the warning and decided to learn it and practice it anyways destroyed their faith.
They learned what could cause discord between a man and his wife... but only if Allah (SWT) allowed it to be effective.
Yes, what they taught was not magic. It is evident from the words of the verse you quoted:
يُعَلِّمُونَ النَّاسَ السِّحْرَ وَ مَا أُنزِلَ عَلَى الْمَلَكَيْنِ بِبَابِلَ هَارُوتَ وَمَارُوتَ
They taught people witchcraft, and that which was sent down to Harut and Marut, the two angels in Babylon. 2:102
It mentions two thing joined by conjunction 'and':
- witchcraft i.e. magic
- that which was sent down to Harut and Marut
Grammatically speaking, the two things being joined by coordinating conjunction 'and' should have some difference. This rule is usually phrased by Arabic grammarians as:
العطف يقتضي المغايرة
Yes they did. but for canceling the magic of evil people. not for evil using. it is like for neutralization of a bomb you should first learn the knowledge of making bomb. those magic then was abused by evil people.
And they followed [instead] what the devils had recited during the reign of Solomon. It was not Solomon who disbelieved, but the devils disbelieved, teaching people magic and that which was revealed to the two angels at Babylon, Harut and Marut. But the two angels do not teach anyone unless they say, "We are a trial, so do not disbelieve [by practicing magic]." And [yet] they learn from them that by which they cause separation between a man and his wife. But they do not harm anyone through it except by permission of Allah. And the people learn what harms them and does not benefit them. But the Children of Israel certainly knew that whoever purchased the magic would not have in the Hereafter any share. And wretched is that for which they sold themselves, if they only knew. http://tanzil.net/#2:102
This knowledge is passed and now can be found in Kabbalah.