Family, friends and senior politicians attended the service for the Livingston MP at St Giles Cathedral in Edinburgh.
Chancellor Gordon Brown said his Labour colleague's death had left a gap "which can never be properly filled".
Mr Cook died last weekend at the age of 59 after falling ill while walking in the Scottish hills.
The mourners were led by Mr Cook's wife Gaynor and his sons from his first marriage, Peter and Christopher. His ex-wife Margaret attended with partner Robin Howie.
His election agent Jim Devine, a close personal friend and the best man at his second wedding, greeted mourners.
Delivering the principal tribute to Mr Cook, the chancellor said his colleague was "taken from us at the height of his powers".
'Greatest parliamentarian'
"His mission and his achievement was not just to make great speeches but to advance great causes - and he did.
"This is how I believe we best remember Robin, not just for what he said and how he said it but what he stood for - the greatest parliamentarian of our time, who put all his talents and his life at the service of the greatest causes of our time.
"Whenever there was injustice he sought to right it, wherever there was poverty he fought a war against it."
Readings were also given by Mr Cook's children, Glasgow MP Mohammad Sarwar and racing pundit John McCririck.
He attacked Prime Minister Tony Blair, who is abroad on holiday and did not attend the service, for delivering a "snub" to the Cook family.
He said his decision "demonstrates a petty vindictiveness and a moral failure, opting to continue snorkelling instead of doing his duty".
However, Mr Devine responded: "John McCririck was wrong to say those things. It is not what Robin would have wanted."
The service was led by the Right Reverend Richard Holloway, former Primus of the Scottish Episcopal Church.
He told mourners that as an avowed atheist Mr Cook would have raised a "quizzical eyebrow" at the service being held in St Giles Cathedral.
But he said it was an "entirely appropriate" venue because, like late First Minister Donald Dewar, Mr Cook was "a Presbyterian atheist".
We meet to give thanks for one of Scotland's greatest sons
Right Reverend Richard Holloway
And he added: "This historic cathedral is not just the home of a Christian church, it is an important place in the civic and community life of Scotland.
"So it is entirely fitting that it is where we meet to give thanks for one of Scotland's greatest sons and in which to express our feeling of sorrow and loss at his untimely death."
Christopher Cook read from his father's political memoir The Point Of Departure, while his brother Peter chose a passage from Germinal by Emile Zola - one of his father's favourite books.
The service also featured a recital by traditional musicians Aly Bain and Phil Cunningham.
Robin Cook took ill while hillwalking
Floral tributes were placed outside the doors of the cathedral on the city's Royal Mile.
The square next to St Giles is usually bustling with festival performers, but was cleared of entertainers for the funeral.
Many people stood behind crowd barriers to watch mourners arrive and then listen to the service on a loudspeaker.
After the service the funeral cortege left for a local cemetery and a private burial.
Mr Cook collapsed while hillwalking in the Scottish Highlands last weekend.
He was pronounced dead in hospital after he fell eight feet down a ridge, near the summit of 2,365ft Ben Stack.
A post-mortem examination concluded that he died from hypertensive heart disease.
Robin Cook
Robin Cook, the former British foreign secretary and current Member of Parliament, has died of a suspected heart attack after collapsing on a walk with his wife on Ben Stack hill, Scotland. Cook, aged 59, was flown to a hospital in Inverness by a rescue service helicopter half an hour after collapsing. 

A spokesperson for NHS Highland said that Mr. Cook arrived at hospital 90 minutes after his collapse, and was reported dead five minutes later. A postmortem examination has concluded that he died from hypertensive heart disease.

Mr. Cook was buried on August 12 at St Giles Cathedral in Edinburgh in a service attended by close family, friends and political figures from across the world. British Prime Minister Tony Blair however came under attack from Mr. Cooks friend and racing pundit John McCririck for his absence from the service.  

Robin Cook served as Foreign Secretary under New Labour and was a critic of the war in Iraq. He  resigned as Leader of the House of Commons in 2003 in protest against Prime Minister Blair's foreign policies.