King Willem-Alexander of the Netherlands apologised Tuesday for his country's aggression during its colonial rule of Indonesia and formally recognised the Southeast Asian country's independence date, in his first state visit to the former Dutch colony.

The Netherlands did not initially apologise for its 350 years of colonial rule and aggression until 2013 when the Dutch ambassador expressed remorse for a series of massacres carried out by the Dutch military to crush resistance against colonial rule in Java and Sulawesi islands after Indonesia's 1945 declaration of independence. That apology came only after the victims' widows took the Dutch government to court.

The king's apology was conveyed after he and Queen Maxima were hosted by Indonesian President Joko Widodo and his wife, Iriana, at an official ceremony in the ornate colonial-style presidential palace in Bogor, just outside the capital, Jakarta.

In line with the previous statement by my government, I would like to express my regret and apologise here for the excessive violence on the part of the Dutch in those years. Willem-Alexander King of the Netherlands

"In line with the previous statement by my government, I would like to express my regret and apologise here for the excessive violence on the part of the Dutch in those years," the king said Tuesday at a joint news conference with Widodo. “I do so with full awareness that the pain and sorrow of the affected families will be felt for generations.”

Indonesia claims, 40,000 killed during anti-colonial resistance

Indonesia declared its independence from Dutch colonial rule on Aug. 17, 1945, but the Netherlands refused to acknowledge it and fought unsuccessfully to maintain control of the lucrative Asian outpost. It finally recognised the country as an independent nation in December 1949.

Indonesian authorities claim some 40,000 people were killed during the fighting, while most Dutch historians estimate the dead at about 1,500.

A 1968 Dutch report acknowledged “violent excesses” in Indonesia but argued that Dutch troops were conducting a “police action” often incited by guerrilla warfare and terror attacks. The Dutch government has never prosecuted any soldiers for the killings despite a U.N. report condemning the attacks as “deliberate and ruthless” as early as 1948.

The 2013 apology by the Dutch ambassador cleared the way for the biggest-ever Dutch trade mission to Indonesia in November 2013, led by Prime Minister Mark Rutte.

Subsequent apologies were made by Dutch Foreign Minister Bert Koenders in 2016 and Rutte late last year during visits in Indonesia. But unresolved demands from those affected by past war crimes still loom large over the monarch's current visit.

"On Aug. 17, it will be 75 years since Indonesia declared its proclamation, claiming its place among free and independent countries," the king said Tuesday. "Today, the Dutch government explicitly acknowledged it both politically and morally."

Netherlands and Indonesia aim to deepen economic ties

The four-day state visit by the royal couple, who arrived in Jakarta on Monday, aims to deepen economic ties with Indonesia. It's the first trip to Indonesia for the king since he ascended the throne in 2013, and the fourth for the queen, whose previous trips were part of her role as U.N. Secretary-General's Special Advocate for Inclusive Finance for Development.

The king and queen started their busy day Tuesday by laying a wreath at the Kalibata Heroes Cemetery to honour Indonesia's war dead, especially those who fell during the War of Independence. In the afternoon, the royal couple laid a wreath at Menteng Pulo Cemetery, the resting place of almost 4,300 Dutch soldiers who died during World War II and the independence war.

The king and Widodo witnessed the signing of agreements for economic partnership in the areas of agriculture, health care, coastal protection and the maritime industry.

Under the Widodo administration, ties between the two countries have strengthened significantly.

"We certainly cannot erase our history, but we can learn from the past," Widodo said. "We try to learn from history to strengthen our commitment to building an equal relationship that respects and benefits each other."

Widodo’s visit to the Netherlands in 2016 was the first by an Indonesian leader since Abdurraham Wahid in 2000. In 2010, then-President Susilo Bambang Yudhoyono cancelled a visit at the last minute amid moves by a separatist group to have him arrested for alleged human rights violations.

The Dutch royal couple is scheduled to meet the Sultan of Yogyakarta on Wednesday. On Thursday, the king and queen will visit Lake Toba in North Sumatra province, one of Indonesia's "10 new Balis," an ambitious plan to boost tourism and diversify Southeast Asia's largest economy. They will also visit Sebangau National Park on Borneo island on Thursday.