Panahi, who is outlawed from travelling abroad and was absent from the festival, appears on screen in the film as a Tehran cab driver, swapping stories with the denizens of the city.
A mounted dashboard camera allowed him to film in secret, away -- at first -- from the prying eyes of the Islamic state's authorities.
The jury president, Hollywood director Darren Aronofsky, said Panahi had overcome restrictions that had the power to "damage the soul of the artist".
"Instead of allowing his spirit to be crushed and giving up, instead of allowing himself to be filled with anger and frustration, Jafar Panahi created a love letter to cinema," Aronofsky said.
"His film is filled with love for his art, his community, his country and his audience."
Panahi was represented on stage by his young niece Hana Saeidi, who appears in the film, and she wept openly as she accepted the statuette.
"I'm not able to say anything, I'm too moved," she said.
The Silver Bear prizes for acting went to Charlotte Rampling and Tom Courtenay for their performances in the British drama "45 Years".
Rampling noted that her father Godfrey had won a gold medal at the 1936 Olympic Games in Berlin and that she had long dreamed of taking "the baton from him".
"Well, I think this Bear has done the trick," she said with a smile.
Courtenay later told reporters he was pleased to make a film featuring an older generation.
"There are lots more old actors than there used to be. We all live longer," he said.
"There are bound to be films that reflect that."
The slow-burn drama by Andrew Haigh shows a couple on the eve of their 45th wedding anniversary whose marriage begins to founder when the husband learns the body of his long-dead first love has resurfaced.
Chilean drama "The Club" by Pablo Larrain about defrocked paedophile priests given refuge from justice by the Roman Catholic Church claimed the runner-up jury prize.
- 'Terrific road movie' -
Signup to our newsletter and follow us on Facebook and Twitter!
Two filmmakers shared the Silver Bear prize for best director, Romania's Radu Jude and Malgorzata Szumowska of Poland.
Jude's "Aferim!" is a black-and-white Balkan Western about a 19th century constable and his son dispatched to track down a runaway gypsy slave. The film explores the roots of contemporary prejudice against Roma.
Szumowska's "Body" tells the story of a Warsaw widower and his anorexic daughter who seek the help of a therapist who believes she can communicate with the dead.
Chilean documentary "The Pearl Button" by Patricio Guzman, a searing indictment of his country's brutal history as told through the image of a single relic, won best screenplay.
"Taxi" is the first Iranian film to win the Golden Bear since Asghar Farhadi's drama of entangled relationships, "A Separation", in 2011.
Panahi's last movie shot in secret, 2013's elegiac "Closed Curtain", won a Silver Bear in Berlin for best screenplay, drawing protest from the Iranian government.
German Foreign Minister Frank-Walter Steinmeier hailed the prize as "an important symbol for artistic freedom".
Film industry bible Variety called "Taxi" a "terrific road movie" that offered "a provocative discussion of Iranian social mores and the art of cinematic storytelling".
The 54-year-old Panahi's work is celebrated in the world's arthouses but outlawed in Iran where the regime considers his gritty, socially critical productions to be subversive.
He was detained for a documentary he tried to make on the unrest following Iran's disputed 2009 presidential election and officially banned from making more films for 20 years for "acting against national security and propaganda against the regime".
In "Taxi", Panahi himself offers his impressions of contemporary Tehran from behind the wheel of a yellow cab.
Each person he offers a lift has a story to tell, an axe to grind or an issue to debate about life in today's Iran.
Panahi proves a genial master of ceremonies, treating his sometimes hysterical fares with unfailing politeness and good humour.
The film builds to a chilling climax in which the extent and limits of the director's liberties are revealed.
Prizes at the 11-day Berlin film festival, which has a reputation for showcasing political cinema, can help propel a picture to global box office success and further honours.
Among award winners last year were "The Grand Budapest Hotel" and "Boyhood", both nominated for Oscars later this month, and the gritty Chinese thriller that won the Golden Bear, "Black Coal, Thin Ice".