What is now San Rafael was once the site of several Coast Miwok villages; Awani-wi, near downtown San Rafael, Ewu, near Terra Linda, and Shotomko-cha, in Marinwood. Mission San Rafael Arcángel was founded in what is now downtown San Rafael as the 20th Spanish mission in the colonial Mexican province of Alta California by three priests—Father Narciso Durán from Mission San José, Father Abella from Mission San Francisco de Asís, Father Luis Gíl y Taboada from La Iglesia de Nuestra Señora Reina de los Angeles—on Dec. 14, 1817, four years before Mexico gained independence from Spain. Mission San Rafael Arcángel was located a donkey's day walk to the mission below it. The mission and the city are named after the Archangel Raphael, the Angel of Healing.
The mission was originally planned as a hospital site for Central Valley American Indians who had become ill at the cold San Francisco Mission Dolores. Father Luis Gil, who spoke several Native American languages, was put in charge of the facility. In part because of its ideal weather, San Rafael was later upgraded to full mission status in 1822. The mission had 300 converts within its first year, and 1,140 converts by 1828. The Mexican government took over the California missions in 1834, and Mission San Rafael was abandoned in 1844, eventually falling into ruin. The current mission was built in 1949 in the style of the original, but faces at right angles to the alignment of the original.
The San Francisco and North Pacific Railroad reached San Rafael in 1879 and was linked to the national rail network in 1888. The United States Navy operated a San Pablo Bay degaussing range from San Rafael through World War II.