The Gaddafi regime carried out an extraordinary clandestine lobbying operation to try to stop Nato's bombardment of Libya, and believed the western allies were likely to launch a full-scale invasion in "either late September or October".

Secret documents in Tripoli seen by the Guardian reveal the desperate attempts made by the Libyan government in its final months to influence US and world opinion. It approached key international opinion formers from the US president Barack Obama downwards.

The regime tried to persuade the Democratic congressman Dennis Kucinich – a well-known rebel who voted against Nato military action in Libya, and opposed the Iraq war – to visit Tripoli as part of a hastily arranged "peace mission". The Libyan government offered to pay all Kucinich's costs related to the trip, including "travel expenses and accommodation".

On 22 June a letter sent to Libya's prime minister, Al-Baghdadi Ali al-Mahmoudi, by a US-based lobbyist for the regime, Sufyan Omeish, noted that Kucinich was "concerned that his personal safety in Tripoli could not be guaranteed". He preferred to conduct meetings with regime officials outside Libya. The plan was for Kucinich to meet "senior Libyan officials, including Gaddafi". The proposed trip never took place. Kucinich visited Syria instead.

He confirmed the invitation and said he had discussed it directly with the Libyan prime minister, but ultimately declined because of security concerns.

"Because of the efforts I had made early on to bring an end to the war, I started to get calls from Libya, including from the prime minister," the congressman told the Guardian. "He had taken note of the fact I was making an effort to put forward a peace proposal. I had several requests to go to Libya. I made it clear I could not negotiate on behalf of the administration. I said I was speaking as a member of Congress involved in the issue and willing to listen to what they had to say. But given that Libyan was under attack, it did not seem a promising place to hold meetings."

He said that on one occasion he held an hour-long telephone conversation with the prime minister. He also confirmed Omeish had been in touch, acting as an intermediary for and supporter of the regime.

On 23 June the prime minister – who has since fled to Tunisia – wrote a surprisingly sycophantic letter to Obama. He addressed him as "Mr President", and politely complained about Washington's "unprecedented decision" to confiscate the Libyan regime's assets – "to please" the rebels. He also wrote to leading members of the US Congress, chiding Republican John Boehner after he described a letter by Gaddafi as "incoherent".

The documents surfaced in a city still subject to a power struggle between rebel fighters and remnants of Gaddafi's security forces, who exchanged fire for much of the day around a cluster of multi-storey blocks of flats in north Tripoli, the site of a last stand by some loyalists.

Rebels also closed in on pro-Gaddafi strongholds in Sirte and Sabha.

Last night the opposition National Transitional Council (NTC) consolidated its control when Ali Tarhouni, the finance minister of the NTC cabinet, told a press conference the cabinet is moving immediately to Tripoli from the eastern city of Benghazi. The NTC also scored a significant diplomatic victory when a Security Council committee last night agreed to unblock $1.5bn (£921m) in Libyan funds that had been frozen since the start of the conflict. The money will be used to pay for humanitarian supplies, basic services in Libyan cities, and salaries for civil servants, police and soldiers who have not been paid in months. The agreement to unblock the funds followed negotiations between the US and South Africa, which had initially opposed the move.

As the NTC was bolstered by these announcements, other secrets of the 42-year regime emerged. The NTC leader, Mustafa Abdel Jalil, said his forces had found huge supplies of food, medicine and fuel secretly stockpiled by the regime. He claimed there was enough food to feed a city twice the size of Tripoli and enough medicine for the entire country for a year.

There was also evidence that both sides may have carried out executions. An international medical worker said 17 bodies found in Gaddafi's fortified compound, Bab al-Aziziya, were of civilians executed there in the last days of the regime. Reuters meanwhile reported finding 30 bodies of pro-Gaddafi fighters with multiple bullet wounds, at least two of which had been bound with plastic handcuffs, suggesting they too had been executed.

Gaddafi's furtive global lobbying took place as the increasingly paranoid regime believed the US was planning to invade. On 28 June, Omeish, a US-based film maker, warned that the US Senate's decision to extend US involvement in Libya for another year paved the way for a ground assault.

The letter to Baghdadi is marked "highly important and strictly confidential". It says: "It is clear that the Nato coalition forces have no intention of ending their military campaign over Libya anytime soon … What is most concerning is that there are highly credible analysts and intelligence personnel in the United States who are exposing growing evidence of covert logistical military planning for a future ground invasion in either late September or October of this year."

He then discusses an urgent proposed peace mission to Libya to try to sway international opinion in their favour. He writes: "We have already obtained confirmation of the involvement of a high-profile US congressman to participate … and are making additional overtures to obtain further congressional involvement from other members.

"Moreover, we have also obtained a new confirmation from a high-profile Princeton professor of international law and a former UN fact-finding commissioner to join our delegation." Omeish boasted that he was also working with "award-winning/Oscar-nominated filmmakers to help document the truth about Libya … to ensure maximum world-wide exposure."

In another message, Omeish urges Baghdadi not to communicate via Gmail, but to use a more secure private account.

His invasion warning was sent to Almois Ben Ismail, Baghdadi's private secretary. The Libyan government's PR offensive had a spectacular lack of success, with Nato continuing its UN-backed air strikes, and rebels sweeping into Tripoli on Sunday. Omeish did not reply to an email seeking comment.

The correspondence seen by the Guardian reveals that the Libyan government was surprisingly well informed – even if its sources were sometimes egregiously inaccurate. Baghdadi's personal papers include copies of the WikiLeaks documents concerning Libya, written by the US ambassador Gene Cretz. Cretz was forced to leave Libya after mentioning Gaddafi's "voluptuous" Ukrainian nurse. Someone had carefully annotated the English original with Arabic.

Baghdadi also had a copy of a letter written by US senator John McCain to Mahmoud Jibril, the chairman of the executive board of the NTC which had been intercepted by the regime. In it, McCain urged Jibril to stop human rights abuses by the rebels, following reports of reprisals including looting, house-burning and beatings against government supporters.

McCain tells Jibril he is a "friend and supporter". But he says the rebels must behave in "positive contrast" to the cruel Gaddafi regime.

The papers list the "talking points" Libyan representatives need to make in their conversations with international partners, specifically to claim that the revolution in Libya is not a popular uprising but the work of al-Qaida cells.

The documents also include occasional glimpses of friction within the regime. One letter complains about Moussa Ibrahim, Gaddafi's media spokesman, one of the key protagonists of the Libya conflict until his disappearance 24 hours ago.

Baghdadi complains that Ibrahim briefed CNN about US-Libyan negotiations in June without consulting him or Libya's minister for media. Another paper details the sacking of two Libyan diplomats in Tunisia, presumably for political disloyalty.

Gaddafi's own missives also feature. The prime minister had a copy of the vanished Libyan leader's rambling appeal to the US congress and senate, in which he expressed his unhappiness about the US's participation in the "aggression against Libya".

Gaddafi blamed the crisis on France. He said that he had been "keen for years to establish a special relationship with the US". He also modestly denied playing a leading role in Libyan affairs, and claimed to have left power in 1977.

"I do not have any formal position, not even the powers of the Queen of Britain," he insisted.

• This article was amended on 26 August 2011 to make clear that John Boehner is not a senator.