Thailand's Senate has rejected a controversial amnesty bill that could have led to the return of former Prime Minister Thaksin Shinawatra.
The amnesty would have applied to offences committed during the political turmoil after Thailand's 2006 coup, which ousted Mr Thaksin.
The bill's passage in the lower house triggered large street protests.
And on Monday, as the bill went to the Senate, tens of thousands of protesters took to the streets of Bangkok.
Prime Minister Yingluck Shinawatra - who is Mr Thaksin's sister - has promised to respect the Senate's decision.
The bill, which was proposed by the governing Pheu Thai party, applied to offences committed during the upheaval after Mr Thaksin was removed from office.
Ms Yingluck's government had argued that the legislation was a necessary step towards reconciliation, after several years of political turmoil.
This turmoil included the occupation of Bangkok's main airport in 2008 and then two months of street protests in Bangkok in 2010 that left about 90 people - mostly civilian protesters - dead.
But critics said it would allow human rights abuses - such as the killing of civilian protesters - to go unpunished.
The main opposition Democrat Party also believed it was aimed at allowing Mr Thaksin to return to Thailand without having to serve a jail sentence.
Mr Thaksin has been in self-imposed exile since his conviction on corruption charges over a property deal. He argues the charges are politically motivated.
The lower house backed the bill, despite an opposition boycott. But as protests gathered strength, the governing party withdrew its support from the bill and all 141 senators present voted against it.
"This house rejects this bill for consideration," said Deputy Senate Speaker Surachai Lengboonlertchai.
As tens of thousands of anti-government protesters remained on the streets in parts of Bangkok on Monday night, a spokesperson for the Pheu Thai party said the governing coalition would not bring the amnesty bill back to parliament.
"We believe from tomorrow the political crisis will start to ease as there are no reasons to maintain the protest," said Pormpong Nopparit.
But the opposition has urged its supporters to observe a three-day national strike, beginning on Wednesday, in what correspondents say has turned into a campaign to bring down the government.
Former leader Thaksin Shinawatra is a deeply polarising figure in Thai politics.
He drew huge support from Thailand's rural poor but strong opposition from other sectors in society, and the divisions dating from the 2006 coup continue to dominate the political landscape.