Prior to the US Civil War the case of Barron v. Baltimore, 32 U.S. (7 Pet.) 243 (1833) established that the restrictions of the Bill of rights were not applicable to the states. In his opinion in that case, Chief Justice Marshall wrote:
The Constitution was ordained and established by the people of the United States for themselves, for their own government, and not for the government of the individual States. Each State established a constitution for itself, and in that constitution provided such limitations and restrictions on the powers of its particular government as its judgment dictated. The people of the United States framed such a government for the United States as they supposed best adapted to their situation and best calculated to promote their interests. The powers they conferred on this government were to be exercised by itself, and the limitations on power, if expressed in general terms, are naturally, and we think necessarily, applicable to the government created by the instrument ...
If these propositions be correct, the fifth amendment must be understood as restraining the power of the General Government, not as applicable to the States.
[I]n a constitution framed by the people of the United States, for the government of all, no limitation of the action of government on the people would apply to the State government, unless expressed in terms, the restrictions contained in the tenth section are in direct words so applied to the States. (This refers to Article I section 10, which contains various limitations on the State governments)
After the Civil War, and the ratification of the 13th, 14th, and 15th amendments, the case of United States v. Cruikshank, 92 U.S. 542 (1876) reaffirmed this view. The opinion, by Chief Justice Morrison Waite held that neither the First Amendment nor the Second Amendment applied to the actions of state governments or to individuals. He further ruled that the Due Process Clause and the Equal Protection Clause of the Fourteenth Amendment applied to the actions of state governments, but not to individuals.
Decades later, starting in the 1920s (although suggested by Twining v. New Jersey (1908)), the US Supreme Court began the Incorporation of the Bill of Rights against the states, holding that particular rights were implicitly included via the "Due Process Clause" of the 14th Amendment. (The use of the "Privileges and Immunities" clause might have seemed more logical, but was held to have been foreclosed by the "Slaughterhouse cases" 83 U.S. (16 Wall.) 36 (1873). Recently Justice Thomas has favored this approach in some concurring opinions. Justice Hugo Black had earlier taken this view in a dissent. Such an approach might limit the protections to US citizens, while the current approach applies to "all persons".)
This was long known as "selective incorporation" because only some provisions of the Bill of Rights, those deemed "Fundamental", were made applicable to the states. Today, most of the provisions fo the first eight amendments have been incorporated, but not the right to a Grand Jury indictment, the right to a jury from the district where a crime occurred, the right against excessive bail and excessive fines, the right to a unanimous 12-member jury, and, in most of the country, the third amendment right assistant the quartering of troops.
The Freedom of Assembly clause of the First amendment was incorporated by De Jonge v. Oregon, 299 U.S. 353 (1937).
The Free Speech clause was incorporated by *Gitlow v. New York, 268 U.S. 652 (1925). The opinion included the statement that:
For present purposes, we may and do assume that freedom of speech and of the press which are protected by the First Amendment from abridgment by Congress are among the fundamental personal rights and "liberties" protected by the due process clause of the Fourteenth Amendment from impairment by the States.
The establishment clause was incorporated by Everson v. Board of Education, 330 U.S. 1 (1947) in which both the majority and minority opinions agreed that the establishment clause applied to the states, although they differed on the effect in that particular case. Justice Black wrote (in the majority opinion):
The "establishment of religion" clause of the First Amendment means at least this: Neither a state nor the Federal Government can set up a church. Neither can pass laws which aid one religion, aid all religions or prefer one religion over another. Neither can force nor influence a person to go to or to remain away from church against his will or force him to profess a belief or disbelief in any religion. No person can be punished for entertaining or professing religious beliefs or disbeliefs, for church attendance or non-attendance. No tax in any amount, large or small, can be levied to support any religious activities or institutions, whatever they may be called, or whatever form they may adopt to teach or practice religion. Neither a state nor the Federal Government can, openly or secretly, participate in the affairs of any religious organizations or groups and vice versa. In the words of Jefferson, the clause against establishment of religion by law was intended to erect "a wall of separation between Church and State."
That holding is the effective basis of all later law that precludes state and local governments from interference with religion, just as the Gitlow decision is the basis for requiring state and local governments to refrain from from punishing free speech.
Some scholars have argued, and some Justices have written, as if incorporation actually happened when the amendments were ratified, and just was not noticed until the 20th century. There is some legals theory to support this view, but it falsifies legal history. Cruikshank and simialr decisions from the 1870s through roughly 1929 make it clear that the Bill of Rights was not being enforced against the states at that time