The power switch could short-circuit, causing parts to overheat and potentially leading to a fire, the company said.
It is the latest in a string of recalls by the carmaker.
Toyota has already recalled some 10 million cars globally that were fitted with faulty air bags linked to a number of deaths.
The defective window switch affects models including the Yaris model as well as the Corolla, Camry, RAV4, Highlander and others.
The recall only affects cars produced between 2005 and 2010.
Of the total, about 2.7 million cars were sold in North America, 1.2 million in Europe, and 600,000 in Japan, the company said.
The firm explained that modules in a switch related to the electric window might have been lubricated inconsistently during manufacturing.
Debris caused by wear from the electrical contact points can accumulate and cause a short-circuit.
This could in turn cause the switch to overheat and melt, potentially leading to a fire.
Toyota said it was not aware of any accidents caused by the glitch.
Japanese carmaker Toyota has said it will recall 6.5 million vehicles globally over a faulty window switch.