Despite his reputation, Boris Johnson is a careful man when it comes to things that matter. And the leadership of the Conservative Party matters a lot.

He may throw out risqué one-liners aplenty, but when he makes a political move it tends to be well-calculated. His mayoralty is a constant, so the variable in his calculation is the position of the Party, and specifically the Prime Minister.

It isn’t so simple as speaking out when Cameron is weakest – to do so would be to risk being seen as a destabilising force. By the same token, senseless opposition to something on which everyone else is united would be seen as egotistical posing.

Instead he picks Goldilocks moments, when the state of things is neither too hot nor too cold. When the temperature is just right, he intervenes.

The same principle applies to the topics he chooses – too close to the bone, and he risks coming across as embittered. Too small or irrelevant, and he loses some of his shine.

Last night’s Margaret Thatcher Lecture to the Centre for Policy Studies was a perfect example of just such an opportunity. The Mayor was more radical than he has been for some time, presumably reassured by the cover of being able to couch his ideas as things the Iron Lady would do, were she Prime Minister today.

He used it to set himself up as the man with some of the answers to the social mobility problem (which, it turns out, is even more serious than many realised).

The speech covered a range of issues, from housing and transport to preserving the union, but it paid particular attention to selective education.

It was a clever choice. Mrs Thatcher was a grammar school girl (though she closed plenty of them in her time, as Boris conceded), so it was on-topic, and the Coalition is rather vulnerable on the issue.

Grassroots and backbench support for selective education remains strong, and Michael Gove’s education reforms are so radical that just about anything is open to debate.

The Education Secretary has a grammar school headache at the moment. The policy of allowing existing grammars to expand is being tested to the limit by an application in Sevenoaks to open a 1,300 pupil “annexe” which is in effect a new school. That won’t have escaped Boris’ notice while the speech was being planned.

The contrast between the leadership’s wariness of allowing new grammar schools and the high level of grassroots Tory support for selective education, reveals why this is a classic Johnson Goldilocks moment.

The speech struck a nerve because it is hard to see why new selective schools should not be allowed if there is demand for them. After all, Gove and the Government prize the principles of localism, freedom from central control and so on.

Johnson intervened on a topic which is not only a Tory vulnerability, but a really confused patch of public policy.

The decision of some private schools to join the state sector has been held up as proof of the progress Gove has made in battling what he calls The Blob and restoring excellence to our schools. Yet as Graham Brady has pointed out, it is bizarre that those schools can only do so by abandoning their selection policies.

The inconsistency goes wider. Pupils can often only get into good comprehensives if their parents are able to pass a form of selection by house price. Other schools are allowed to select based on religion.

Meanwhile, selection by straighforward ability remains restricted.

All of this makes the ideal setting for a Boris outing.

Some of the others who aspire to lead the Conservative Party must envy the freedom of speech his job provides. The more Goldilocks moments he has, the more they will be concerned he might eat their porridge.