People gazed at the sky in wonder and cheered while others knelt in prayer as a total eclipse of the sun unfolded over Indonesia on Wednesday, briefly plunging cities into darkness and startling wildlife.

The rare astronomical phenomenon was witnessed along a narrow path that stretched across 12 Indonesian provinces encompassing three time zones and about 40 million people. A partial eclipse was visible in other parts of the Indonesian archipelago, a swath of Asia and in northern Australia.

APTOPIX India Solar Eclipse

An Indian fisherman prays to a solar eclipse seen in the sky over Bay of Bengal in Konark, 60 kilometres (37 miles) from eastern Indian city Bhubaneswar, India, Wednesday, March 9, 2016, where it was viewed as a partial solar eclipse. (Biswaranjan Rout/Associated Press)

Thousands of eclipse-chasers flocked to Indonesia from abroad and the government, which has been the promoting the event for more than a year, forecast a substantial tourism boost. Some tour groups chartered ships to view the eclipse, which began in the Indian Ocean and ended in the Pacific, at sea. A dozen Americans joined a commercial flight from Anchorage, Alaska, to Honolulu because its flight path would rendezvous with an eclipse sweet spot north of Hawaii.

India Solar Eclipse

Indian people in northeast and eastern coastal strip of the sub-continent viewed a partial solar eclipse as a total eclipse of the sun unfolded over Indonesia on Wednesday, briefly plunging cities into darkness and startling wildlife. (Mahesh Kumar A./Associated Press)

Thousands of men, women and children who gathered in Sigi Biromaru, a hilltop town of Indonesia's Central Sulawesi province, shouted and clapped as the sun transformed into a dark orb for more than two minutes. Hundreds of others prayed at nearby mosques.

"The sun totally disappeared. How amazing this sunny morning suddenly changed to dark," said Junaz Amir, a Sigi resident who witnessed the eclipse with his family using special protective glasses.

Indonesia Total Solar Eclipse

A total solar eclipse is seen in Luwuk, Central Sulawesi, Indonesia, Wednesday, March 9, 2016. A total solar eclipse was witnessed along a narrow path that stretched across Indonesia while in other parts of Asia a partial eclipse was visible. (Irmansyah/Associated Press)

In Ternate, one of the last cities in the eclipse's path, some residents said they were viewing it by looking at the reflected image in bowls of water. Experts say the total eclipse can be viewed with the naked eye but specific filters should be used during its partial phases to avoid permanent damage to the retina.

APTOPIX Cambodia Solar Eclipse

The moon is obscuring part of the sun over flowers during a solar eclipse in Phnom Penh, Cambodia, Wednesday, March 9, 2016. (Heng Sinith/Associated Press)

Most eclipses are partial but when the moon is close enough to the Earth, the sun is completely eclipsed by the moon's shadow and only a spectacular ring of rays known as the corona is visible.

The last time a total eclipse occurred over Indonesia was in 1988. Unfounded fears and misinformation caused panic, with people papering windows and keeping children indoors.

Cloudy skies in parts of Indonesia dampened the spectacle for some. In Palembang, a Sumatran city of more than 1.4 million, thousands of residents from mothers carrying infants to old men gathered at its landmark Ampera bridge from well before dawn. But the total eclipse was only briefly visible if at all.

"Too bad we cannot see when the total solar eclipse occurred, but the dark atmosphere when it happened made us feel happy," said Palembang resident Martha Sembiring.

There was also disappointment for a group of six eclipse chasers who travelled from Canada and the U.S. to Kalimantan.

"Unfortunately we got nothing because we had rain showers and solid cloud," said optometrist Ralph Chou who was hoping to see his 19th total solar eclipse.

Chou, a Canadian who helped develop the international standards for eclipse filters, said there were still impressive effects of light and darkness, and birds appeared confused and disoriented by dark falling again after dawn.

The previous total solar eclipse was in March last year and was best viewed on Norway's Svalbard islands near the North Pole. The next total eclipse will occur in August 2017 and be visible over a slice of North America.

The entire eclipse, which began with the first patch of darkness appearing on the edge of the sun, lasted about three hours.

SOLAR-ECLIPSE/

A pigeon is silhouetted as the sun goes into a partial solar eclipse in Kathmandu, Nepal, March 9, 2016. (REUTERS)

For the viewer, the length of time the sun was totally eclipsed depended on their location along the path. On land the durations were mostly between one and three minutes.

In the capital, Jakarta, thousands of residents packed a planetarium at a downtown park where officials distributed about 4,000 filtered viewing glasses that quickly ran out. The eclipse, which from the vantage point of Jakarta produced an impressive crescent, was also streamed on monitors around the planetarium.

Scientists from NASA and Indonesia's aerospace agency observed the eclipse from Maba in the Maluku islands.

Total solar eclipse

Here's a view of the eclipse at 7:23 p.m. ET on Tuesday (12:23 p.m. Wednesday over Micronesia). (Exploratorium/NASA)