Ismael Saibari was also on target in another workmanlike display in which Morocco were efficient enough, but also created little in the way of chances, netting from two of their three shots on target.
Cameroon had a strong shout for a penalty in the second half after what looked a foul on Bryan Mbeumo but they too battled in the final third and did not force home goalkeeper Yassine Bounou into a save in the 90 minutes.
Morocco will now face the winner of Saturday's third quarter-final between Algeria and Nigeria in the next round, a tie that will be played in Rabat on Wednesday.
The hosts took the lead in the 26th minute via the prolific Diaz as the Real Madrid player showed his scoring instinct. Achraf Hakimi's corner was headed goalwards by Ayoub El Kaabi and Diaz deflected the ball in from close range.
He has now scored in each of Morocco's five games and extends his own record for most goals by a Moroccan at a single Cup of Nations finals, but left the field late on with a heavily strapped thigh that will be a concern for coach Walid Regragui.
Chances were hard to come by for both sides, but Abde Ezzalzouli headed narrowly over the crossbar from another Hakimi corner, while the latter laid on a headed chance for Saibari that was spurned.
Cameroon were unfortunate not to get a penalty kick when Mbeumo was caught in the box as Mauritanian referee Dahane Beida waved play on, while Georges-Kevin Nkoudou headed wide at the back post with the Indomitable Lions' best chance of the game.
Morocco made it 2-0 minutes later to kill off the contest when Saibari was left unmarked at the back post and had time to control the ball and fire low into the far corner of the net.
Iliman Ndiaye's first-half strike was enough for Senegal to beat 10-man Mali 1-0 in the first quarterfinal.
Ndiaye poked the ball home from close range in the 27th minute after Krépin Diatta's cross slipped through Mali 'keeper Djigui Diarra's fingers and landed at Ndiaye's feet.
Mali captain Yves Bissouma was already booked for a foul on Sadio Mané as his team made a courageous start, and the Eagles' hopes took a major blow when he was shown a second yellow card before the break for a foul on Idrissa Gueye.
Referee Abongile Tom had already sent off Woyo Coulibaly in Mali's previous game, a penalty shootout win over Tunisia, and Bissouma's sending off represented the team's third sending off in as many games.
Abdoulaye Diaby had Mali's best chance before the hour mark but his shot was too close to Senegal keeper Édouard Mendy.
Otherwise all the chances were at the other end; Diarra saved from Lamine Camara and Mané in stoppage time.
The 2021 champions await the winner between Ivory Coast and Egypt in the first semi-final, also in Tangier, on Wednesday.