The draw for the qualifying stage was held on 3 July 2017, 11:00, at the CBF headquarters in Rio de Janeiro. Teams were seeded by their 2017
CBF ranking (shown in parentheses). The eight teams were drawn into four ties, with the Pot A teams hosting the second leg. : The draw for the group stage was held on 6 September 2017, 21:00, at the Auditório da Federação das Indústrias do Estado do Maranhão (FIEMA) in
São Luís. For the group stage, the 16 teams were drawn into four groups (Groups 1–4) of four containing a team from each of the four pots. Teams were seeded by their 2017
CBF ranking (shown in parentheses) excluding the winners of the qualifying stage, which were allocated to Pot 4. : ==Qualifying stage==