For many years he would go to bed early listening to what ants whispered in his ear. Sometimes he would chat with a frog or two, maybe share a hunk of bread with some rats. José Mujica, aka Pépé, is a survivor from a world he himself wiped off the map. A former leader of the Marxist Tupamaros, the country's main guerrilla group, he spent 13 years in prison under the military dictatorship in Uruguay, which held power from 1973 to 1985. Then he turned over a new leaf and devoted his efforts to restoring democracy.

In November 2009 he was elected president, polling 53% of the vote. "Locked up, I almost went mad," he says. "Now I'm a prisoner of my own freedom to think and decide as I wish. I cultivate that freedom and fight for it. I may make mistakes, some huge, but one of my few virtues is I say what I think."

To see him today, now aged 78, sitting on his wooden chair, surrounded by books and silence, a pair of sandals on his feet and a bust of Che Guevara opposite him, you might take Mujica for some Latino Diogenes, a benevolent patriarch, the last man on Earth and obviously indignant. He is also one of the few people to have experienced nothingness, spending two years' captivity at the bottom of a well.

He describes himself as a "humble peasant", meeting us at his small farm out in the countryside, about half an hour's drive from Montevideo. He speaks of himself and his native Uruguay in the first person plural: "We are a republican voice for the world." By which, one supposes, he means a possible future, a path, however modest, to take for the common good with politics as its ethical base and honesty as its guiding light. "I re-read Plato in search of keys to understand what is going on, for nothing is completely new," he explains. A very personal way of recalling the warning he issued to the United Nations general assembly in September 2013: "Politics, which should rule human relations, has succumbed to economics and become a mere administrator of what the financial system does not control."

The international media have described him as "the most incredible politician" or indeed "the best leader in the world". Some have suggested he should win the next Nobel peace prize. He is also thought to be the world's poorest president, because he gives almost 90% of his income to low-income housing organisations. He is not very keen on such labels. "My definition of poverty is the one we owe to Seneca: It is not the man who has too little, but the man who craves more, who is poor."

Predictably he is now the object of Mujicamania, sufficient to make some of his opponents forget he was once a guerrillero belonging to a movement that kidnapped people and robbed banks. Indeed his fellow-travellers are often among his harshest critics, mainly because he wouldn't support repeal of the amnesty for acts of torture committed under the dictatorship.

The US magazine Foreign Policy nevertheless included him in its leading global thinkers of 2013. "When Venezuelan President Hugo Chávez died in March, many assumed that the resurgent Latin American left would die with the blustering populist in the red shirts [...] In breaking with Chávez's overt anti-Americanism and also with Latin America's deep-seated social conservatism, Mujica is pointing to a possible path forward for his comrades."

Mujica excelled on the campaign trail. At no point in the presidential campaign did he consider watering down his manifesto. Not once did he temper his discourse to attract opposition votes, a stance he later explained to the Brazilian weekly Carta Capital. "Even during summit meetings with world leaders," he explained, "leaders tell me I'm right. But nothing happens. That's why I go on repeating the same things. You have to persist and try to convince people." To which he added, with a smile: "I have the aggressive courage to speak out. It's not done in the modern world, where people conceal and disguise their feelings. Maybe that's why I get people's attention."

José Mujica, left, with two other members of the Tupamaros guerrilla group on 14 March 1985, the day of their liberation as political prisoners. Photograph: Agencia Camaratres/AFP/Getty

After two years in office Mujica legalised abortion up to the third month of pregnancy. Even with substantial restrictions, this law is unique in South America. Less than a year later a bill authorising same-sex marriages was passed. Uruguay legalised divorce in 1913. "Yes, we have an innovatory spirit, deeply rooted in our history," he asserts. "We're a country of immigrants, anarchists and persecuted people from all over the world. The result is the most secular country in Latin America, with a clear distinction between church and state. For my part, I'm president but I don't believe in God." You would never hear anything of the sort in neighbouring countries. But in June 2013 he received a warm welcome when he met Pope Francis.

The pinnacle of his presidential career came in June 2012 when defence minister Eleuterio Fernández Huidobro announced that the state would be taking over the production and sale of marijuana, which would be legalised and regulated. Compared with the experiments under way in the US, in Colorado and Washington, in the Netherlands and Spain, this system seemed so avant garde that the journalists present thought it might be a hoax. But the bill was passed and came into force last month.

Before the end of this year, by which time a new crop will have grown and a market set up, adult Uruguayan consumers registered with the authorities will be able to purchase up to 40g of marijuana a month at chemists, paying $1 per gram. It will be produced and marketed under government control. Consumers will also be allowed to grow their own in a neighbourhood co-operative or indeed at home, limited to no more than six plants per household. Somehow this is typical of Mujica, who says he has never smoked a joint and knows very well that 62% of voters are opposed to legalisation, yet has no qualms about launching the world's first state-grown marijuana. He says it is a question of public security and that he is determined to separate consumers from dealers, and marijuana from other narcotics.

Drug trafficking has reached alarming levels in Latin America but has spared Uruguay, where the number of users is relatively low. "There's a saying among farming people here," Mujica explains. "When you see your neighbour's beard on fire, you drench your own." Adding, with a smile: "This law is a trial. It doesn't mean we have the final answer. But our neighbours will have to take a look at our little country which might actually be a perfect location for this experiment." He pushes his chair back. "The only thing I'm sure of is that the policy of combating drugs which has been enforced for decades is a crashing failure. I'm glad we've kicked over the ant hill."

Members of his inner circle acknowledge that Mujica only recently became interested in the issue. But they hasten to add he researched and read a lot on the topic, often on his own, before making up his mind, in agreement with only a few members of the government. "Only someone like him would dare commit themselves to such an unpopular decision," says the young member of parliament Sebastian Sabini, who helped draft the bill. "Mujica is already a historic figure and is not afraid, a bit like François Mitterrand when he abolished capital punishment," says political scientist Adolfo Garce, pointing out that the Tupamaros were always slightly transgressive, "rather obsessed with the idea of shocking middle-class values". Perhaps that is why he agreed to Barack Obama's request to take five prisoners from Guantánamo.

Mujica sees himself as an anarchist, "but we all have our inner conflicts", he says. Then in a sudden outburst he adds: "I think recognition of gay marriage, abortion and the law on marijuana all represent progress. But they will really achieve something when there is less of a gap between the poor, the destitute and the very rich." He stands up. Neither the landline on his small desk nor his mobile have rung in the past two hours. "Everyone knows I don't like it, so people rarely call," he says, before stepping outside.

To see him posing for a photograph alongside his three-legged dog and his two blue Volkswagen Beetles reminds of a comment by political commentator and well-known Mujica critic Graziano Pascale. He said Mujica resembled "a slightly potty old uncle, like you find in every family". He may indeed be a bit crazy, but he is also captivating and quite unique among world leaders. He says goodbye and turns to look at his wooden chair, suggesting he wants to get on with his extraordinary life and his books. "You know what getting old means? No longer wanting to leave home."

This article appeared in Guardian Weekly, which incorporates material from Le Monde

This article was modified on 3 June to rephrase the description of Graziano Pascale in the last paragraph.