The KGB played a major role in the collapse, centrally in the attempted coup.
In 1990, the Chairman of the KGB was a man named Vladimir Kryuchkov. Kryuchkov was a powerful man in the USSR, a strong supporter of communism, a member of the Politburo, and had several key victories against the West in gaining vital intelligence. He had risen to power as the protege of Yuri Andropov, who himself rose to power as leader of the Communist Party. Kryuchkov was also what you might call a 'true believer', a communist hardliner. Seeing reforms put in place by Mikhail Gorbachev as liberal reforms, Kryuchkov and Communist party leaders attempted a political coup.
The writing was already on the wall, for many, before this happened. The KGB was, after all, an intelligence agency. While they were diligently engaged in spy work for the USSR, there was an understanding that domestic instabilities were reaching a head.
Kryuchkov's coup was the final nail in the coffin. The KGB collapsed into chaos, temporarily. The coup only lasted three days, but the USSR collapsed soon after.
The KGB was officially disbanded, however many former KGB workers ended up either at the FSB (Federal Security Service) or SVR (Foreign Intelligence Service). While the KGB is gone, former KGB still remain in seats of power and influence in Russia, including President Putin.
Russia's intelligence/security apparatuses have a long history of being reshuffled and reorganized while maintaining many of the more ruthless policies associated with them. The Czars' Okhrana became the Soviet Cheka, then OGPU, then NKVD, then MGB, and finally the KGB. Genrikh Yagoda, Nikolai Yezhov, and Lavrenty Beria and their executioner Vasili Blokhin (most prolific personal killer of all time) have some morbidly fascinating careers and are worth a wikipedia look.
Oh right, the question. As DeletedByMods said, KGB leaders conspired with Vice-President Gennady Yanayev and other military and political leaders as the "Gang of Eight" in the "August Coup" of 1991 to force Gorbachev to effectively step down and allow them to undo the effects of perestroika and glasnost which they believed were killing the Soviet Union. The opening of archives from glasnost in particular revealed the tremendous scale of Stalin's atrocities, first revealed in Khrushchev's "Secret Speech" in 1956. A lot of the taint from the NKVD's actions during the "Great Terror" was then associated with the KGB and helped further undermine the state.
The big issue in the August Coup was the New Union Treaty, which would have established the former Soviet Union as the Union of Sovereign States, a confederation without the Soviet Union's de facto RSFSR (Russian Soviet Federative Socialist Republic) hegemony. They surrounded Gorbachev at his dacha and cut his lines of communication. Yeltsin got wind of the conspiracy and raced to the "White House" where the Supreme Soviet met. He famously rallied a crowd while standing on a tank. The "Gang of Eight" conspirators appeared on TV saying Gorbachev's "illness" meant Yanayev would replace him, but they were shaking and terrified and people were less than impressed. The troops they dispatched to the Red Square refused to fire on the crowd, much like the Czar's troops refused to fire in the February Revolution of 1917.
The actual end to the Soviet Union came in a Belarussian hunting lodge, where Russian President Yeltsin met with Leonid Kravchuk and Stanislav Shushkevich, the Ukrainian President and Belarussian Prime Minister. The latter two just saw a chance to achieve independence, while Yeltsin simply wanted to ouster his politically moribund rival, (General Secretary) Gorbachev. The final nail in the USSR came from a simple political rivalry :).
The KGB wasn't quite the terror by 1991 that it had been in earlier decades. East Germany's Stasi, for example, were a good deal harsher. As it had been many times, the KGB was disbanded and reorganized into an alphabet soup of agencies. Its direct successor was the Federal Counterintelligence Service (FSK), which eventually became the Federal Security Service (FSB). The GRU (Main Intelligence Directorate) is also a huge intelligence agency, foreign intelligence, which the Spetsnaz belong to. These agencies have done some interesting things, but 1994+ breaks the 20 year rule so I'll cut it off.
If you have access to jstor, there are quite a few articles on the KGB around 1991, like Was the Soviet System Reformable? by Stephen F. Cohen and
[Beyond Perestroika: Soviet-Area Archives after the August Coup, by Patricia Kennedy Grimsted] (http://www.jstor.org.proxy-bc.researchport.umd.edu/stable/10.2307/40293629?Search=yes&resultItemClick=true&&searchUri=%2Faction%2FdoAdvancedSearch%3Fc5%3DAND%26amp%3Bc4%3DAND%26amp%3Bc6%3DAND%26amp%3Bc1%3DAND%26amp%3Bc3%3DAND%26amp%3Bc2%3DAND%26amp%3Bed%3D%26amp%3Bf0%3Dall%26amp%3Bpt%3D%26amp%3Bq2%3D%26amp%3Bf2%3Dall%26amp%3Bf3%3Dall%26amp%3Bwc%3Don%26amp%3Bf1%3Dall%26amp%3Bf6%3Dall%26amp%3Bisbn%3D%26amp%3Bf4%3Dall%26amp%3Bf5%3Dall%26amp%3Bsd%3D%26amp%3Bacc%3Don%26amp%3Bq3%3D%26amp%3Bla%3D%26amp%3Bq1%3D%26amp%3Bq0%3Daugust%2Bcoup%2Bkgb%26amp%3Bq6%3D%26amp%3Bq5%3D%26amp%3Bq4%3D).
This thread has generated a lot of poor answers that we mods have had to delete.
I would like to ask people to keep in mind the expectations for a quality answer.