Mr Morales said his strike had achieved "something important"
Bolivian President Evo Morales has ended his five-day hunger strike after the upper house of parliament, the Senate, passed a new electoral law.
The constitutional changes allow Mr Morales to run for a second term in office in elections in December.
The bill also gives greater political power to Bolivia's indigenous majority, to which Mr Morales belongs.
The opposition-controlled house had been blocking the bill, saying it would aid the re-election of Mr Morales.
Mr Morales had been sleeping on a mattress on the floor of the presidential palace for five nights, drinking chamomile tea and chewing coca leaves, a traditional appetite suppressant.
In the early hours of Tuesday morning, Mr Morales confirmed that the Senate had approved the bill and he was ending the strike.
"Happily, we have accomplished something important," he told a news conference.
"We have the electoral law with which to prepare, so that in December the people have the power.
"The people should not forget that you need to fight for change. We alone can't guarantee this revolutionary process, but with people power it's possible."
The bill sets an election date for Bolivia of 6 December.
The bill assigns seven seats to indigenous Bolivian minorities
It reserves seven of the 130 seats in the lower house for minority indigenous groups and extends voting rights to Bolivians living overseas.
The opposition succeeded in having measures such as an improved voter registration system built into the bill.
Senate leader and opposition lawmaker Oscar Ortiz said they had contributed "a series of proposals to ensure that democracy, freedom and above all the right of all Bolivians to participate in clean elections be respected".
Tensions had flared last week when members of the governing party, which controls the lower house, clashed with the opposition over the bill.
Opposition politicians described Mr Morales' hunger strike as "ridiculous" and accused him of trying to blackmail parliament.
Mr Morales said that the passing of the bill meant it was now possible "to exert influence over those small partisan groups who are always obstructing in the National Congress".
The Andean nation has been marked by decades of political upheaval.
A new constitution designed to give more rights and a greater share of the land and resources to the country's indigenous majority was approved by more than 60% of voters in late January.
But tensions and deep division between the poorer, indigenous majority located in the highlands, and the wealthier and mixed-race lowlanders, have increased since Mr Morales took office three years ago, the BBC's Andres Schipani reports from La Paz.