On July 6, 2017, Kesha released a single, titled "Praying". The single charted successfully at number 6 on the music charts of Australia, selling over 140,000 copies and being certified 2x Platinum in the country. The single charted at number 22 and number 11 in the United States and Canada respectively, and subsequently was certified Platinum in both territories. "Praying" was released as the lead single from Kesha's third studio album, Rainbow, which was released on August 11, 2017. Rainbow debuted at number one on the Billboard 200 chart in the United States, becoming her second number-one album in the country, and was the subject of universal acclaim from music critics, with several complimenting the album's feminist angle and uniqueness as well as Kesha's vocal performance and ability to interweave different music genres. Three tracks from Rainbow were released as promotional singles ahead of the album's release; "Woman", "Learn to Let Go" and "Hymn", two of which were released with accompanying music videos. "Learn to Let Go" was later released as the second single from the album in November 2017. The album received nominations for Best Pop Vocal Album and Best Pop Solo Performance (for "Praying") at the 60th Annual Grammy Awards, marking Kesha's first Grammy nominations.
To promote Rainbow, Kesha embarked on the Rainbow Tour (2017–2019), which began on September 26, 2017, in Birmingham, Alabama, and visited North America, Europe, Oceania, and Asia. She furthered promotion by joining a co-headlining concert tour with American rapper Macklemore named The Adventures of Kesha and Macklemore (2018). This tour took place in North America between June 6, 2018 and August 5, 2018. Kesha's documentary film, Rainbow: The Film, was released on Apple Music on August 10, 2018. The documentary chronicles her stint in rehab for her eating disorder and the creation of Rainbow. In the same month, Kesha collaborated with British rock band The Struts on the remix of their song "Body Talks", released as a single from their album Young & Dangerous (2018). On September 19, 2018, Kesha released her song "Here Comes the Change", which served as a single to promote On the Basis of Sex (2018), a biographical film about Ruth Bader Ginsburg. In October 2018, Kesha collaborated, wrote, and performed on the song "Safe" with her younger brother Sage Sebert and rapper Chika, as an homage for the Parkland, Florida school shooting.