Capitalism is commonly taken as an economic system, that can be grafted onto any political system, as economics is not a self-evident primary. An economic system (in our case, the free-market) does not exist in a vacuum but, like a house or skyscraper, is an expression of a specific intellectual foundation — a philosophy.
What is philosophy?
One’s view of what is the proper social system for human beings depends on how one views the nature of existence, how one grasps the world one lives in, and how one views human nature. It depends on one’s philosophy — an integrated, systematic view of existence.
According to philosopher Ayn Rand, philosophy consists of three primary branches:
Metaphysics is the branch of philosophy that studies the nature of reality (that which is); it answers the question: “what kind of world do I live in?”
Epistemology (epistēmē is the Greek word for knowledge) is the branch of philosophy that studies the nature and means of human knowledge, of grasping reality; it answers the question: “how do I know it?”
Ethics is the branch of philosophy that defines a code of values that one should live by. It answers the question: “what should I do?”
The answers to these fundamental questions will, in part, determine the answers to the branch of philosophy known as politics. Politics being the application of ethics to social issues. Politics seeks to answer, “how should one live with other individuals in an organized society?”
The importance of philsophy
Philosophy is important. It is not a mere plaything of ivory-tower professors or a “…bauble of the intellect, ” writes Professor Leonard Peikoff,” but a power from which no man can abstain. Anyone can say that he dispenses with a view of reality, knowledge, the good, but no one can implement this credo. The reason is that man, by his nature as a conceptual being, cannot function at all without some form of philosophy to serve as his guide.” 
If one’s philosophy is that one lives in a world of miracles (religion), where truth is by revelation (faith), and morality means sacrificing oneself for others (altruism), one’s politics will be very different from someone who believes in a world of cause and effect (science), that one can understand rationally (reason), to pursue and achieve personal happiness (self-interest).
To concretize this point further, observe that if one’s philosophy is that of a religious fundamentalist then abortion is murder, and a fetus has the right to live in a woman’s body irrespective of the woman’s thoughts on the subject. Life comes from God, and what God giveth let no man (or women) take away.
If one is an advocate of statism, then the individual has no rights but lives by permission of the state, and the government can revoke (alienate) this permission at whim. The right to abortion becomes a matter of dictatorial vote, i.e., political might makes ethical right. The state may force one to have an abortion or prevent one from having an abortion.
If one is an advocate of individual rights, abortion is an inalienable right, since there is no such thing as the right to live inside the body of another. The choice of whether to have an abortion or not is up to the individual.
Politics is an inseparable branch of the tree of philosophy. Separate a fruitful branch from the tree of good philosophy, and graft it onto the tree of bad philosophy and that once fruitful branch will wither, crumble and die.
Philosophy is a matter of life and death.
It is on the withered cross of anti-reason, altruistic (self-sacrificial), collectivist philosophy that capitalism is being crucified.
The philosophy of anti-capitalism
In philosopher Ayn Rand’s view, the reason why capitalism is attacked and misrepresented (even by its alleged defenders) is because of the anti-enlightenment philosophies that dominate our culture:
“It is often asked: Why was capitalism destroyed in spite of its incomparably beneficent record? The answer lies in the fact that the lifeline feeding any social system is a culture’s dominant philosophy and that capitalism never had a philosophical base. It was the last and (theoretically) incomplete product of an Aristotelian influence. As a resurgent tide of mysticism engulfed philosophy in the nineteenth century, capitalism was left in an intellectual vacuum, its lifeline cut. Neither its moral nature nor even its political principles had ever been fully understood or defined. Its alleged defenders regarded it as compatible with government controls (i.e., government interference into the economy), ignoring the meaning and implications of the concept of laissez-faire. Thus, what existed in practice, in the nineteenth century, was not pure capitalism, but variously mixed economies. Since controls necessitate and breed further controls, it was the statist element of the mixtures that wrecked them; it was the free, capitalist element that took the blame.
“Capitalism could not survive in a culture dominated by mysticism and altruism, by the soul-body dichotomy and the tribal premise. No social system (and no human institution or activity of any kind) can survive without a moral base. On the basis of the altruist morality, capitalism had to be—and was—damned from the start.” 
It is the altruist-collectivist moral base that capitalism must be “saved” from.
Laissez-faire capitalism is a political-economic system that requires a specific philosophical framework. If capitalism is built upon an improper philosophical base, it will be like a towering skyscraper built on quicksand.
The philosophy of capitalism
What is the proper philosophical base? In the words of the American philosopher Ayn Rand:
“It is . . . by reference to philosophy that the character of a social system has to be defined and evaluated. Corresponding to the four branches of philosophy, the four keystones of capitalism are: metaphysically, the requirements of man’s nature and survival—epistemologically, reason—ethically, individual rights, politically, freedom.” 
This site holds that the philosophy that provides a proper foundation for capitalism is Ayn Rand’s revolutionary philosophy: Objectivism.
Objectivism holds that one should live by one’s mind and efforts, in the pursuit of one’s rational self-interest, neither sacrificing oneself to others, nor sacrificing others to oneself (ethics); that one can understand reality by reason and logic (epistemology), as one lives in a world of cause and effect where there are no contradictions (metaphysics).
A complete, systematic presentation of Objectivism is beyond the scope of this site. For a comprehensive presentation of Rand’s philosophy, I recommend Objectivism: The Philosophy of Ayn Rand by Dr. Leonard Peikoff.
“Philosophy is the goal toward which religion was only a helplessly blind groping. The grandeur, the reverence, the exalted purity, the austere dedication to the pursuit of truth, which are commonly associated with religion, should properly belong to the field of philosophy.” — AYN RAND 
Religion affirms the supernatural, faith, and altruism
Religion is a pre-philosophical outlook of the world (that attempts to provide a comprehensive view of existence) that affirms the supernatural, faith, and altruism.
In metaphysics, religions such as Christianity, affirm the supernatural and miracles (as opposed to the natural and causality), in epistemology religion declares revelation and faith as one’s means of knowledge and grasping truth (as opposed to reason and logic), in ethics religion preaches self-sacrifice of altruism (as opposed to the selfishness of pursuing one’s happiness).
The result of such a religious outlook is in principle identical to the “Materialistic mysticism” of Marxist atheists: some form of statism that denies the rationality of the individual human mind to justify the altruistic theory of self-sacrifice for the “greater good.” (In the case of atheistic statists they intellectually substitute society for god, though the effects are the same). The political system based on religion is as a theocracy (Theos being the greek word for god.)
Capitalism depends on the natural, reason, and self-interest (te pursuit of happiness)
The philosophical case for capitalism is based on the recognition of the primacy of existence (“A is A”), the acceptance of reason as an individual’s only means of objectively knowing reality (“reason as an absolute”), and the preservation of human existence requires the pursuit of one’s rational self-interest. To these three pillars, religion as a fundamental belief system stands, in principle, opposed.
This is not to say that the religions of the world, do not have some good (rational) advice to offer (albeit on a contradictory, mystical base), but in terms of fundamentals to the extent that a religious doctrine is actually religious (irrational, based on faith), it is destructive of human life and all it depends upon. 
Notes & References
 Ayn Rand, “The Chickens’ Homecoming” Return of the Primitive: The Anti-Industrial Revolution46  Comments Ayn Rand on this issue in a Playboy Interview (March 1964):
PLAYBOY: Has no religion, in your estimation, ever offered anything of constructive value to human life? RAND: Qua religion, no — in the sense of blind belief, belief unsupported by, or contrary to, the facts of reality and the conclusions of reason. Faith, as such, is extremely detrimental to human life: it is the negation of reason. But you must remember that religion is an early form of philosophy, that the first attempts to explain the universe, to give a coherent frame of reference to man’s life and a code of moral values, were made by religion, before men graduated or developed enough to have philosophy. And, as philosophies, some religions have very valuable moral points. They may have a good influence or proper principles to inculcate, but in a very contradictory context and, on a very — how should I say it? — dangerous or malevolent base: on the ground of faith.
For further study:
“Religion vs. America” by Leonard Peikoff In this 1986 lecture given at the Ford Hall Forum, Dr. Peikoff discusses the profound irreconcilability between religion and the pro-reason philosophy upon which America was founded.
Capitalism is the social system that protects the individual’s freedom to live their life according to their own philosophical beliefs (whether religiously inspired or not), so long as their actions do not violate the rights of others.
Under capitalism, the state neither supports nor opposes religion, as long as those religious practices do not violate the rights of others.
Religious freedom is not a fundamental right but is a derivative of the right to life
Religious freedom is not a fundamental right but is an application of the right to life to a particular context: the freedom to form one’s own conscious beliefs and the freedom to act on those beliefs.
Such freedom is not an out-of-context absolute (anarchy) but is only an absolute within the context defined by the concept of individual rights. “A ‘right’ is a moral principle defining and sanctioning a man’s freedom of action in a social context.” [Ayn Rand, “Man’s Rights”]
Religious freedom arises because an individual has the right to act (right to life and right to liberty) in the pursuit of their self-interest (the pursuit of happiness), so long as they respect the rights of others.
Thus, an individual is free to promulgate their views (freedom of speech) — religious, scientific, political, philosophical, or otherwise — but has no right to force others to agree with them (freedom of thought) or to force them to support one’s beliefs financially (right to property). 
Politically, capitalism requires tolerance of *rights-respecting* religious beliefs and practices
Politically, all that the government requires of individuals in regards to the religious (or any social) practice of others is tolerance.
Tolerance is the refusal to initiate physical force (coercion) against individuals whom one does not approve.
Tolerance does not mean personal acceptance. It means one is free to not associate with such an individual: to leave them alone and to be left alone.
Thus, if a photographer does not wish to photograph a “gay wedding,” it is their inalienable right to do so (the right to free association). That this is “discriminatory” is not the issue as all decisions and acts are acts of discrimination — of making choices — from choosing a car to choosing one’s mate. There is no such thing as the “right” to force someone to photograph your wedding if they do not voluntarily agree to do so.
Capitalism bans all religious practices which violate the rights of others
A rights-respecting, capitalist country bans any religious tenant which necessitates the violation of the rights of others — from preventing women from having an abortion to stoning a woman for wearing a bikini in public — as there is no such thing as religious freedom to violate the rights of others. Under capitalism, religion does not have any privileged status. One’s religious freedom ends where the freedom of others begins.
Capitalism is not validated on religious grounds (faith) but on an objective, rational moral code (reason)
Though the political principle of rights is based on an objective (and not religious) moral code, it is not the government’s mission to force people to be moral.  Under capitalism, individuals are free to act irrationally, against their rational self-interest — by whim, on faith, or by emotion — so long as they do not violate the rights of others.
 “The legitimate powers of government tend to such acts as are injurious to others. But it does me no injury for my neighbor to say there are twenty gods, or no God. It neither picks my pocket nor breaks my leg.” — Thomas Jefferson
 An interesting observation of this is Thomas Jefferson who in his Autobiography,
“…an amendment was proposed by inserting the words, ‘Jesus Christ … the holy author of our religion,’” which was rejected “by a great majority in proof that they meant to comprehend, within the mantle of its protection, the Jew and the Gentile, the Christian and the Mohammedan, the Hindu, and the Infidel of every denomination.”
And in the words of James Madison,
“While we assert for ourselves a freedom to embrace, to profess and to observe the religion which we believe to be of a divine origin, we cannot deny an equal freedom to those whose minds have not yet yielded to the evidence which has convinced us.”