Security Transaction Tax (STT) was first introduced in the Union Budget 2004.
The idea of STT was born after it was found that there were cases of capital gains taxes evasion through real and fictitious losses. Thus, STT came into being as a way of realizing the actual potential of taxing the stock markets. So, while long-term capital gains (LTCG) tax was exempted, STT was introduced to make sure there was no tax evasion. And then, LTCG too made a comeback in 2019.
In essence, STT is an indirect tax and is imposed on a broker rather than the investor/trader directly. The broker, in turn, collects it from its clients and deposits it with the government.
An investor or trader has to pay the tax no matter whether she makes a profit or not.
STT is currently imposed on equity and derivative transactions.
Futures and options transactions come under the purview of STT on the sell-side. Understandably, the rates on futures and options transactions are comparatively lower than on direct equities since such contracts are valued notionally.
Sale of equity funds also attracts STT. This means that even when you redeem equity funds, you are liable to pay STT on the value of the sale.