The plane, which was carrying 147 passengers, was forced to land in Cairns, according to a report in the Australian newspaper The Sydney Morning Herald.
Small flames on the flight deck of the Airbus A330-200 were initially put out by the automatic safety systems.
But the fire began again minutes later, forcing the three pilots, who were wearing oxygen masks, to use a fire extinguisher.
Qantas said the fire was caused by an electrical problem in the system that heats the windscreen, the same fault that forced a Jetstar A330-200 en route from Japan to Australia to land on the Pacific island of Guam in 2009.
One passenger on board the flight told the newspaper that the incident had been 'truly scary'.
The 56-year-old said: 'There was a burning smell in the cabin that was very strong, and then the captain came over the loudspeaker and explained an electrical problem meant there was a serious risk of fire.
'Later he explained flames had come back for a second time and they'd had to use a fire extinguisher in the cockpit.
But the passenger also praised the captain for his calmness during the situation: 'He was very composed over the loudspeaker and when the plane landed he took the time to walk back and talk to the passengers.'
The fire began at 3.35pm Sydney time. The plane arrived in Cairns 50 minutes later.
A Qantas pilot told the Herald that such faults were potentially 'very serious'.
'With that electrical malfunction a circuit-breaker system should trip out and the problem go away. That the flames came back means there was another fault,' he said.
A Qantas spokesman praised the pilots and said the airline had notified the Australian Transport Safety Bureau. ''The pilots did a fantastic job to bring the situation under control and calmly redirected the plane to Cairns Airport for a standard, but unscheduled, landing.'
57 pilots found drunk in charge of an aircraft