A Sunday school is an educational institution, usually (but not always) Christian in character. Other religions including Buddhism, Islam, and Judaism have also organised Sunday schools in their temples and mosques, particularly in the West.
Sunday school classes usually precede a Sunday church service and are used to provide catechesis to Christians, especially children and teenagers, and sometimes adults as well. Churches of many Christian denominations have classrooms attached to the church used for this purpose. Many Sunday school classes operate on a set curriculum, with some teaching attendees a catechism. Members often receive certificates and awards for participation, as well as attendance.
Sunday school classes may provide a light breakfast. On days when Holy Communion is being celebrated, however, some Christian denominations encourage fasting before receiving the Eucharistic elements.
Sunday schools were first set up in the 18th century in England to provide education to working children. William King started a Sunday school in 1751 in Dursley, Gloucestershire. Robert Raikes, editor of the Gloucester Journal, started a similar one in Gloucester in 1781. He wrote an article in his journal, and as a result many clergymen supported schools, which aimed to teach the youngsters reading, writing, cyphering (doing arithmetic) and a knowledge of the Bible.
The Sunday School Society was founded by Baptist deacon William Fox on 7 September 1785 in Prescott Street Baptist Church of London. The latter had been touched by articles of Raikes, on the problems of youth crime.  Pastor Thomas Stock and Raikes have thus registered a hundred children from six to fourteen years old. The society has published its textbooks and brought together nearly 4,000 Sunday schools. 
In 1785, 250,000 English children were attending Sunday school. There were 5,000 in Manchester alone. By 1835, the Sunday School Society had distributed 91,915 spelling books, 24,232 New Testaments and 5,360 Bibles. The Sunday school movement was cross-denominational. Financed through subscription, large buildings were constructed that could host public lectures as well as providing classrooms. Adults would attend the same classes as the infants, as each was instructed in basic reading. In some towns, the Methodists withdrew from the large Sunday school and built their own. The Anglicans set up their own National schools that would act as Sunday schools and day schools. These schools were the precursors to a national system of education.
The role of the Sunday schools changed with the Education Act 1870 which provided universal elementary education. In the 1920s they also promoted sports, and ran Sunday school leagues. They became social centres hosting amateur dramatics and concert parties. By the 1960s, the term Sunday school could refer to the building and rarely to education classes. By the 1970s even the largest Sunday school had been demolished. The locution today chiefly refers to catechism classes for children and adults that occur prior to the start of a church service. In certain Christian traditions, in certain grades, for example the second grade or eighth grade, Sunday school classes may prepare youth to undergo a rite such as First Communion or Confirmation. The doctrine of Sunday Sabbatarianism held by many Christian denominations encourages practices such as Sunday school attendance as it teaches that the entirety of the Lord's Day should be devoted to God; as such many children and teenagers often return to church in the late afternoon for youth group before attending an evening service of worship.
See also: History of education in England
The first recorded Sunday school opened in 1751 in St Mary's Church, Nottingham. Hannah Ball made another early start, founding a school in High Wycombe, Buckinghamshire, in 1769. However, the pioneer of Sunday schools is commonly said to be Robert Raikes, editor of the Gloucester Journal, who in 1781, after prompting from William King (who was running a Sunday School in Dursley), recognised the need of children living in the Gloucester slums; the need also to prevent them from taking up crime. He opened a school in the home of a Mrs Meredith, operating it on a Sunday - the only day that the boys and girls working in the factories could attend. Using the Bible as their textbook, the children learned to read and write.
In 18th-century England, education was largely reserved for a wealthy, male minority and was not compulsory. The wealthy educated their children privately at home, with hired governesses or tutors for younger children. The town-based middle class may have sent their sons to grammar schools, while daughters were left to learn what they could from their mothers or from their fathers' libraries. The children of factory workers and farm labourers received no formal education, and typically worked alongside their parents six days a week, sometimes for more than 13 hours a day.
By 1785 over 250,000 children throughout England attended schools on Sundays. In 1784 many new schools opened, including the interdenominational Stockport Sunday School, which financed and constructed a school for 5,000 scholars in 1805. In the late-19th century this was accepted[by whom?] as being the largest in the world. By 1831 it was reported that attendance at Sunday schools had grown to 1.2 million. 
The first Sunday school in London opened at Surrey Chapel under Rowland Hill. By 1831 1,250,000 children in Great Britain, or about 25 per cent of the eligible population, attended Sunday schools weekly. The schools provided basic lessons in literacy alongside religious instruction.
In 1833, "for the unification and progress of the work of religious education among the young", the Unitarians founded their Sunday School Association, as "junior partner" to the British and Foreign Unitarian Association, with which it eventually set up offices at Essex Hall in Central London.
The work of Sunday schools in the industrial cities was increasingly supplemented by "ragged schools" (charitable provision for the industrial poor), and eventually by publicly funded education under the terms of the Elementary Education Act 1870. Sunday schools continued alongside such increasing educational provision, and new forms also developed such as the Socialist Sunday Schools movement, which began in the United Kingdom in 1886.
The earliest recorded Sunday school programme in Ireland goes back to 1777 when Roman Catholic priest Daniel Delany – later (1787) Bishop Daniel Delany of Kildare and Leighlin – started a school in Tullow, County Carlow. This was a complex system which involved timetables, lesson plans, streaming, and various teaching activities. This system spread to other parishes in the diocese. By 1787 in Tullow alone there were 700 students, boys and girls, men and women, and 80 teachers. The primary intent of this Sunday school system was the teaching of the Catholic faith; the teaching of reading and writing became necessary to assist in this. With the coming of Catholic Emancipation in Ireland (1829) and the establishment of the National Schools system (1831), which meant that the Catholic faith could be taught in school, the Catholic Sunday school system became unnecessary.
The Church of Ireland Sunday School Society was founded in 1809. The Sabbath School Society of the Presbyterian Church in Ireland was founded in 1862.
The concept of Sunday school in Sweden started in the early to mid-1800s, initially facing some backlash before becoming more mainstream as it was often intertwined with the growth (and eventual legalization) of free churches. The first documented Sunday school was started in 1826 in Snavlunda parish, Örebro County, by priest Ringzelli, and was still active during the time of Pastor Lennart Sickeldal in the 1950s. Ringzelli was also an early organizer of school meals for students who lived far from the school or were from poor families.
Carl Ludvig Tellström, later missionary to the Sámi people, made another early attempt to start a Sunday school around 1834. While in Stockholm, he was converted by George Scott, an influential Scottish Wesleyan Methodist preacher who worked in Sweden from 1830–1842 and was controversial due to his preaching in violation of the Conventicle Act. Within the Church of Sweden, however, based on the format of Methodist Sunday schools, he started several in Flykälen, Föllinge, Ottsjön, Storå, and Tuvattnet.
Later, Mathilda Foy founded an early Sunday school in 1843–1844. Influenced by Pietistic revivalist preachers such as Scott, and particularly Carl Olof Rosenius, Foy found herself part of the läsare (Reader) movement. Always engaged in charitable work, she started a Sunday school not long after her spiritual awakening. However, it was soon closed due to the protests of clergy, who considered it "Methodist". Another attempt by Augusta Norstedt was noted around the same time.
Sometime between 1848 and 1856, educator and preacher Amelie von Braun, also part of the revivalist awakening movement, started a Sunday school primarily teaching children Bible stories. She worked within the state church. Her Sunday school was supported by Peter Fjellstedt and grew quickly, with 250 students noted in 1853.
Around 1851, Sunday schools were established by Foy's friends Betty Ehrenborg (1818–1880) and Per Palmqvist (1815–1887), brother of Swedish Baptist pioneers Johannes and Gustaf Palmquist. That year, Ehrenborg and the brothers traveled to London. The brothers, at least, reconnected with Scott, whom they knew from Sweden. In England, they studied the Methodists' Sunday schools and teaching methods, impressed by the number of students and teachers. There were over 250 children and 20 to 30 teachers; classes were taught by laypeople and included literacy training in addition to Bible lessons, singing, and prayer.
Upon Palmqvist's return to Sweden, he invited 25 local poor children and founded the first Baptist Sunday school; the same year, Ehrenborg began a Sunday school as well, with 13 mostly Baptist and free-church students. Palmqvist was given £5 in financial support by the London Sunday School Association and used the money to travel to Norrland, home of a significant revival movement, to spread the idea of Sunday school there. The first Sunday school association in Sweden, Stockholms Lutherska Söndagsskolförening, was started in 1868. However, even despite the abolition of the Conventicle Act in 1858 and increasing religious freedom, there were still challenges: Palmqvist was reported to the Stockholm City Court by a priest in 1870 for teaching children who did not belong to his congregation but was later acquitted.
In Stockholm alone, there were 29 Sunday schools by 1871. By 1915 there were 6,518 Sunday schools in the country among a number of denominations, with 23,058 officers and teachers and 317,648 students.
The first Sunday schools in Finland were run by the Evangelical Lutheran Church of Finland, with the first one founded in 1807. They were often for those who had not become literate. As a form of schooling, they were recommended by the state in 1853. Some Sunday schools gave vocational training in the trades; after 1858 they were also preparatory schools for further education held during the week. However, Sunday schools did not catch on until the later growth of free churches in the country as well as the establishment of public schooling, at which point they became a form of children's religious education. One of the earliest free-church Sunday schools was founded by sisters Netta and Anna Heikel in Jakobstad in the 1860s. More Sunday schools were soon founded in the 1870s and 1880s: in Vaasa – including by the local Lutheran parish, in Kotka, Turku, Åland, Helsinki, Ekenäs, Hanko, and other cities.
The first organized and documented Sunday school in the United States was not founded in New England, but rather in Ephrata, Lancaster County, Pennsylvania by an immigrant from Germany, Ludwig Höcker, the son of a well-respected and influential Reformed Church Pastor and teacher in Westerwald. Ludwig immigrated in the 1730's and joined the Sabbatarian Ephrata Cloister in 1739 where he soon created the Sunday school for the impoverished children of the area, and published, on the Ephrata Press, a full textbook. “It is especially interesting to us to know that a Seventh Day Baptist Sabbath school was organized about 1740, forty years before Robert Raikes Sunday-school. This Sabbath school was organized at Ephrata, Pa., by Ludwig Hocker among the Seventh Day Baptist Germans, and continued until 1777, when their room with others was given up for hospital purposes after the battle of Brandywine…”
The American Sunday school system was first begun by Samuel Slater in his textile mills in Pawtucket, Rhode Island, in the 1790s. Notable 20th-century leaders in the American Sunday school movement include: Clarence Herbert Benson, Henrietta Mears, founder of Gospel Light, Dr. Gene A. Getz, Howard Hendricks, Lois E. LeBar, Lawrence O. Richards and Elmer Towns.
Philanthropist Lewis Miller was the inventor of the "Akron Plan" for Sunday schools, a building layout with a central assembly hall surrounded by small classrooms, conceived with Methodist minister John Heyl Vincent and architect Jacob Snyder.
John Heyl Vincent collaborated with Baptist layman B. F. Jacobs, who devised a system to encourage Sunday school work, and a committee was established to provide the International Uniform Lesson Curriculum, also known as the "Uniform Lesson Plan". By the 1800s 80% of all new members were introduced to the church through Sunday school.
In 1874, interested in improving the training of Sunday school teachers for the Uniform Lesson Plan, Miller and Vincent worked together again to found what is now the Chautauqua Institution on the shores of Chautauqua Lake, New York.
In Evangelical churches, during worship service, children and young people receive an adapted education, in Sunday school, in a separate room.
Historically, Sunday schools were held in the afternoons in various communities, and were often staffed by workers from varying denominations. Beginning in the United States in the early 1930s, and Canada in the 1940s, the transition was made to Sunday mornings. Sunday school often takes the form of a one-hour or longer Bible study which can occur before, during, or after a church service. While many Sunday schools are focused on providing instruction for children (especially those sessions occurring during service times), adult Sunday-school classes are also popular and widespread (see RCIA). In some traditions, the term "Sunday school" is too strongly associated with children, and alternate terms such as "Adult Electives" or "religious education" are used instead of "Adult Sunday school". Some churches only operate Sunday school for children concurrently with the adult worship service. In this case, there is typically no adult Sunday school.
In Great Britain an agency was formed called the Religious Tract Society which helped provide literature for the Sunday school.
In the United States the American Sunday School Union was formed (headquartered in Philadelphia) for the publication of literature. This group helped pioneer what became known as the International Sunday School Lessons. The Sunday School Times was another periodical they published for the use of Sunday schools. LifeWay Christian Resources, Herald and Banner Press, David C Cook, and Group Publishing are among the widely available published resources currently used in Sunday schools across the country.
Sunday school teachers are usually lay people who are selected for their role in the church by a designated coordinator, board, or a committee. Normally, the selection is based on a perception of character and ability to teach the Bible rather than formal training in education. Some Sunday school teachers, however, do have a background in education as a result of their occupations. Some churches require Sunday school teachers and catechists to attend courses to ensure that they have a sufficient understanding of the faith and of the teaching process to educate others. Other churches allow volunteers to teach without training; a profession of faith and a desire to teach is all that is required in such cases.
It is also not uncommon for Roman Catholic or Protestant pastors (church ministers) to teach such classes themselves. Some well-known public figures who teach, or have taught, Sunday school include Space Shuttle astronaut Ronald J. Garan Jr., comedian Stephen Colbert, novelist John Grisham, and former U.S. president Jimmy Carter.