The man, thought to be in his 50s, was seen ranting and also pressing another six-inch blade to his chest, while holding a set of beads.
As a policeman shot him with the Taser, he lunged at the officer, taking a series of swipes before the electrical charge knocked him to the ground.
The drama unfolded as hundreds of tourists and Londoners gathered outside the palace for the midday changing of the guard.
Witnesses said the suspect, who was arrested on suspicion of affray, broke through a barrier and was walking towards the guards when he was stopped by police who were "on him in seconds".
A video posted on YouTube shows the bespectacled man shouting and walking round while holding the knives against his body before an officer stuns him with the charge.
He was quickly surrounded and the weapons kicked out of harm's way while officers checked him over.
Eyewitness Kevin Burrows, 33, from Surrey, said the man broke through a cordon as the changing of the guard was about to happen.
The kitchen porter said: "I thought, 'Oh my God, I can't believe it'. There must have been about 15 police officers on foot who surrounded him once he'd been Tasered. The police saw him really quickly and were obviously cautious.
"He was in his 40s I'd say and I think he had knives in both hands.
"Everybody was standing back when it happened and people were actually quite calm, I think everyone was surprised.
"They had to divert the procession away from him. I think he was making his way to the guards. The man didn't have the chance to get close to anyone as the police were right on him in seconds."
The Queen and the Duke of Edinburgh were at Sandringham at the time of the incident.
A scene was cordoned off with police tape 30 yards from the palace gates, and an ambulance was parked to the side of the building.
Inside the cordoned-off area lay the two knives, a pair of Nike high-top trainers, the man's hat and a black carrier bag containing paper and material. A handkerchief lay beside the bag.
The scene created confusion among those tourists who had not seen the incident.
After the suspect was taken into custody and the procession had finished, tourists arriving at the palace asked police if the items were part of an exhibition.
"It is not what you expect to see outside Buckingham Palace," one holidaymaker said.