Venezuelan presidential candidate Nicolas Maduro celebrates after the official results gave him a victory in the balloting, in Caracas Sunday. Reuters

Nicolas Maduro, Venezuela’s former leader Hugo Chavez’s preferred successor, narrowly won Venezuela's presidential election on Sunday, but his rival refused to concede and demanded a recount.

Maduro, who represents the ruling United Socialist Party of Venezuela, or PSUV, won 50.7 percent of the vote against 49.1 percent for opposition candidate Henrique Capriles, the governor of Miranda state and the candidate for the umbrella opposition group Table for Democratic Unity, or MUD.

Capriles said he did not recognize official results with a difference of just 235,000 ballots between the two candidates.

“Mr. Maduro, if you were illegitimate before, now you are even more loaded with illegitimacy,” Capriles said, alleging thousands of “incidents” during the vote from gunshots to the reopening of polling centers after their official closure, Reuters reports.

“I didn't fight against a candidate today but against the whole abuse of power,” Capriles said. “It is the government that has been defeated.” Then, addressing Maduro, he said, “The biggest loser today is you. The people don't love you.”

Though opposition supporters chanted “fraud” and protested, Capriles did not call them onto the streets.

The National Electoral Council said Maduro's victory was “irreversible” and gave no indication of holding a recount. Maduro has given his support to a full recount even as he insisted his victory was clean, Reuters reports.

The results were announced at 23:15 local time (3:45 GMT), and celebrations erupted in the capital, Caracas, where Maduro's jubilant supporters set off fireworks.

In a victory speech outside the presidential palace, Maduro said his victory was “just, legal and constitutional.”

He said his election showed Chavez “continues to be invincible, that he continues to win battles,” BBC reports.

He called for those who had not voted for him to “work together” for the country.

Maduro's margin of victory was far narrower than Chavez’s 10 percent margin against Capriles in the election last October.

Maduro had been one of Chavez’s closest advisors and is described by people close to him as a quiet and calm man who appears to have a spiritual side. He and his wife used to travel to India to listen to the teachings of Indian spiritual guru Sathya Sai Baba, who died in 2011, BBC reports.

Despite his quiet disposition, Maduro is said to be friendly and jovial, enjoys socializing and at the same time is credited with being a wily operator and a skilled negotiator, according to BBC.

He is due to be sworn in on Friday and serve until January 2019 to complete the six-year term.