In recent years, many studies on scheduling problems with dedicated machines have been carried out. But, few of them have considered the case of more than two stages. This paper aims at filling this gap by addressing the three-stage hybrid flow shop scheduling problem with two dedicated machines in stage 3. Each job must be processed, consecutively, on the single machines of stages 1 and 2, and depending on its type, it will be further processed on one of the two dedicated machines of stage 3. The objective is to find an optimal schedule that minimizes the maximum completion time (makespan). Since this problem is strongly NP-hard, we first provide some basic results including solutions for several variations of the problem. Then, for the general case we adapt a set of lower bounds from the literature and propose a heuristic approach that is based on the dynamic programming technique, which uses a local search procedure. Finally, various experimentations on several problems with different sizes are conducted and the computational results of the heuristic show that the mean percentage deviation value from the lower bound was lower than 0.8 percent for some instances with 40 to 200 jobs in size.