Exiled Queen Mother Frederika of Greece, a controversial figure in Greek public life, died last night in Madrid of heart failure a few hours after undergoing what was described as eyelid surgery. She was 63.

Frederika had gone to Madrid to visit her daughter, Queen Sofia of Spain. Frederika was the mother-in-law of Spain's king, Juan Carlos. Her son, King Constantine of Greece, was overthrown in a 1967 coup and since then the family had lived in exile. Her husband, King Paul, died in 1964.

A granddaughter of the German kaiser and a great-granddaughter of England's Queen Victoria, the German-born, 5-foot-3-inch queen mother was reputed to be a tough, domineering, often disdainful woman who was both courageous and intelligent.

She was linked through one of her actions to the turbulent events that led to the 1967 coup, an attempted countercoup and the family's ultimate exile. l

During a visit to London in 1963 she was roughly treated by demonstrators demanding clemency for Communists imprisioned in Greece. Fearing more demonstrations, Greek Premier Constantine Karamanlis advised King Paul to cancel a state visit to London later that year.

Frederika prevailed on her husband to go ahead with the trip. Karamanlis resigned. Demonstrations erupted, and Karamanlis' resignation was said to have opened the way for a leftist resurgence that in turn led to the coup by right-wing military officers.

When the throne passed to Constantine after the death of King Paul, Frederika became queen mother, saw her son daily and continued to be politically influential.