In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In his response to your question, Prof. Dr. Monzer Kahf, Professor of Islamic Finance and Economics at Qatar Faculty of Islamic Studies, states:
Stocks/shares are basically of two kinds: common and preferred. If the preference is in preferred shares in financial transactions such as guaranteed minimum return, priority in payment at time of liquidation and the like, preferred stocks/shares are then prohibited because equal owners of the companies’ principal must be treated equally.
They are forbidden to issue, buy, own and sell. If the preference is managerial, they may be permissible. Common stocks are not prohibited from this point of view.
From another angle, stocks/shares may belong to companies that are fully compatible with the Shari`ah in establishment and all activities such as Islamic Banks, to companies whose main and major business is forbidden such as conventional banks or Las Vegas type entertainment companies, or to companies whose main/major business is permissible but their articles of incorporation allow them to undertake activities that are prohibited in the Shari`ah and their management actually do such activities, this category covers most companies on the stock exchanges such as Microsoft, Intel, Sony, General Motors, etc. because they are involved in at least one kind of impermissible transaction, i.e., Riba-based borrowing and/or lending.
Obviously, the Shari`ah ruling on issuing, buying, owning and selling the first category is permissible while prohibited on the second.
The third category is troublesome and needs certain details. It is prohibited for a Muslim to establish a company that gets indulged in prohibited activity and consequently, it is also prohibited to issue its stocks and offer them to the public for sale.
In principle, it is also prohibited to buy and own such a stock because by doing so the owner becomes in fact a partner in the company whose management takes up prohibited activities on behalf of all its owners as their deputed officers.
In other words, the management acts as your agent, this means, you are doing this prohibited activity.
In this regard, two points are important. If one buys such stocks with the intention (that is coupled with ability) to convert such a company into all halal activities through having a majority in its board and general assembly, such a purchase is certainly permissible because it narrows the scope of haram (unlawful) in the world, although the process may take a few month or may be a year or two.
The second point (that may be more relevant to the questioner) is buying and owning such stocks as small investor and a small minority holder to get benefit from expected capital gains and from dividends.
A small group of Muslim scholars argue that this category of stocks may be purchased and owned for investment within certain conditions that can be summarized in being sure that the prohibited activities do not make a high percentage of the total activity of the company.
These include that the company does not have high rate of liability/asset, i.e., it does not live on loans, it does not earn a lot on interest, it is not involved in activities that basically hurt the interests of Muslims, such as producing and selling arms to people who attack Muslim Ummah.
Based on these conditions, Dow Jones, in cooperation with a group of Muslim Scholar, studied the registered stocks and make a list that is issued under the name of Islamic Market Dow Jones Index.
Almighty Allah knows best.