Wiranto, who was armed forces chief in the late 1990s, had just stepped out of his auto and was being welcomed by the police chief in Pandeglang when the attacker dashed towards them, wounding both along with the third man.
Officials say the minister is in stable condition.
The attack came just over a week before Widodo's inauguration for his second five-year term in office. Police said he was in stable condition and conscious after the attack.
National police spokesperson Dedi Prasetyo confirmed the incident and told media the perpetrator had been arrested and an officer had been hurt.
Wiranto, 72, who uses one name, was airlifted to the capital, Jakarta.
The head of the hospital said the surgery should take about two hours.
In the incident at 11.50 am West Indonesian time, Wiranto, 72, who arrived in Alun-alun Menes, Pandeglang to attend an event with the local people was getting out of a vehicle when the man attacked him.
Police have arrested a man and a woman, and are trying to determine their motive.
Police said Alamsyah had been "exposed to ISIL radicalism", without elaborating.
"While very serious, this attempt should not be over dramatized".
Wiranto was indicted by a United Nations panel over the bloodshed surrounding East Timor's 1999 independence vote, when about 1,000 people were killed.
Wiranto ran unsuccessfully for president in 2004 and for vice president in 2009.
Aside from a failed attack on the South Sulawesi governor in 2011, it was the first time in recent history that militants had been this close to an assassination of such a senior figure in Indonesia, she said.