Dame Stella Rimington, the first female director general of MI5, has died aged 90.

Described as the “housewife superspy” when she came into the role, she was widely credited as the model for Dame Judi Dench’s M in the James Bond films.

She was born on 13 May 1935 in South Norwood, south London, and died on Sunday night.

Her family said in a statement that she died “surrounded by her beloved family and dogs and determinedly held on to the life she loved until her last breath”.

Rimington was recruited by MI5 in 1965 when she accompanied her husband on a diplomatic posting to New Delhi. She worked for the agency as a part-time clerk typist in its office in the British high commission until 1969, when she returned to the UK and joined full-time.

She served as director of each of the service’s operational branches – counter-subversion, counter-espionage and counter-terrorism – before she was appointed deputy director general in 1991 and then director general a year later.

During her time in the top job between 1992 and 1996 there were threats from the IRA and Russia, while the Islamist terror threat was also starting to emerge.

Rimington was the first director general of MI5 to be publicly named by the agency on her appointment. Later, when a newspaper published a photo of her house, she and her family had to move to a covert location for their own protection.

After leaving MI5 in 1996, Rimington began a career as a novelist.